Excel - Binary和Text两种Compare方法

Option Compare statement
VBA里可以定义默认使用的compare方法:
' Set the string comparison method to Binary.
Option Compare Binary ' That is, "AAA" is less than "aaa".
' Set the string comparison method to Text.
Option Compare Text ' That is, "AAA" is equal to "aaa".
This example uses the Option Compare statement to set the default string comparison method. The Option Compare statement is used at the module level only.
If used, the Option Compare statement must appear in a module before any procedures.
If a module doesn't include an Option Compare statement, the default text comparison method is Binary.

  • Option Compare Binary results in string comparisons based on a sort order derived from the internal binary representations of the characters. In Microsoft Windows, sort order is determined by the code page. A typical binary sort order is shown in the following example:

A < B < E < Z < a < b < e < z < À < Ê < Ø < à < ê < ø

  • Option Compare Text results in string comparisons based on a case-insensitive text sort order determined by your system's locale. When the same characters are sorted by using Option Compare Text, the following text sort order is produced:

(A=a) < ( À=à) < (B=b) < (E=e) < (Ê=ê) < (Z=z) < (Ø=ø)
参考:
Option Compare statement (VBA) | Microsoft Learn

相关推荐
Xiaouuuuua4 小时前
多项日常使用测试,带你了解如何选择AI工具 Deepseek VS ChatGpt VS Claude
笔记
学游戏开发的4 小时前
UE求职Demo开发日志#12 完善击杀获得物品逻辑和UI
笔记·游戏引擎·unreal engine
鲁子狄5 小时前
[笔记] 极狐GitLab实例 : 手动备份步骤总结
linux·运维·笔记·ubuntu·centos·gitlab
花生_TL000078 小时前
C语言小笔记(一)
c语言·开发语言·笔记
siy23338 小时前
[C语言日寄] <stdio.h> 头文件功能介绍
c语言·笔记·学习·算法
Good Note9 小时前
Golang笔记——常用库context和runtime
开发语言·redis·笔记·后端·面试·golang·春招
Suwg20910 小时前
《Effective Java》学习笔记——第7部分并发
java·笔记·学习
Ronin-Lotus11 小时前
上位机知识篇---Linux的shell脚本&搜索、查找、管道
linux·笔记·学习·shell脚本·管道·搜索·查找
先知demons12 小时前
【无标题】
笔记
向上的车轮14 小时前
OpenEuler学习笔记(十四):在OpenEuler上搭建.NET运行环境
linux·笔记·学习·.net