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

相关推荐
Tom@敲代码6 小时前
js学习笔记-01
javascript·笔记·学习
巴巴媛6667 小时前
STM32学习笔记【32.BKP + RTC】
笔记·stm32·学习
能摆一天是一天8 小时前
Spring ai vectorstore 使用本地模型导致只能匹配可行度为1.0的内容的解决方法笔记
java·笔记·spring
进阶的DW9 小时前
Wiki + Graph + RAG 知识库建设笔记2
笔记
AOwhisky9 小时前
Linux(CentOS)系统管理入门笔记(第四期)——文件系统(下篇):文件与目录操作实战——cpmvmkdirrmln
linux·运维·笔记·centos·云计算·文件系统
bmy-happy9 小时前
网安专业课程笔记sale
笔记
浩瀚地学10 小时前
【Java基础复习】IO流(二)
java·开发语言·经验分享·笔记·学习
智者知已应修善业11 小时前
【利用proteus设计微型CPU,完成寻址相加数据的过程。】2025-2-26
驱动开发·经验分享·笔记·硬件架构·proteus·硬件工程
学计算机的计算基11 小时前
二叉树算法下篇:递归核心技巧与高频面试题详解
java·笔记·算法
my_power52011 小时前
大模型概述学习笔记
笔记·学习