语 法:
Option Compare { Binary | Text | Database }
备 注:
如果使用 Option Compare 语句,则该语句必须在 模块中出现在任何 过程之前。
Option Compare 语句为模块指定了 字符串比较方法(Binary、Text 或 Database)。 如果模块不包括 Option Compare 语句,则默认文本比较方法为 Binary。
Option Compare Binary 根据派生自字符的内部二进制表示形式的 排序顺序生成字符串比较。 在 Microsoft Windows 中,排序顺序由代码页决定。 典型二进制排序顺序如以下示例中所示:
A < B < E < Z < a < b < e < z < à < ê < Ø < à < ê < ø
Option Compare Text 会导致基于由您系统的 区域设置决定的区分大小写的文本排序顺序的字符串比较。 当使用 Option Compare Text 对相同的字符进行排序时,将生成以下文本排序顺序:
(A=a) < ( à=à) < (B=b) < (E=e) < (ê=ê) < (Z=z) < (Ø=ø)
Option Compare Database 只能在 Microsoft Access 中使用。 这将导致基于由执行字符串比较的数据库的区域设置 ID 决定的排序顺序的字符串比较。
示 例:
此示例使用 Option Compare 语句设置默认字符串比较方法。 Option 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".