Table of contents
TOC
折叠目录
展开目录

Option Compare 语句Option Compare Statement

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

用于在模块级声明比较字符串数据时要使用的默认比较方法。Used at module level to declare the default comparison method to use when string data is compared.

语法Syntax

比较选项{二进制 |文本 |数据库}Option Compare { Binary |Text |Database }

备注如果使用,则选项比较语句必须出现在模块中所有过程之前。比较选项语句指定模块的字符串比较方法 (二进制文本数据库)。如果模块不包含选项比较语句,则默认文本的比较方法是二进制的。比较二进制选项会导致基于从字符的内部二进制表示形式派生的排序顺序的字符串比较。在 Microsoft Windows 排序顺序取决于代码页。在下面的示例显示了典型的二进制排序顺序:Remarks If used, the OptionCompare statement must appear in amodule before anyprocedures. The Option Compare statement specifies thestring comparison method ( Binary, Text, or Database ) for a module. If a module doesn't include an OptionCompare statement, the default text comparison method is Binary. Option Compare Binary results in string comparisons based on asort 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'slocale. When the same characters are sorted using Option Compare Text, the following text sort order is produced:

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

选项比较仅可以在 Microsoft Access 中使用数据库。这将导致基于由字符串比较其中出现的数据库的区域设置 ID 的排序顺序的字符串比较。OptionCompareDatabase can only be used within Microsoft Access. This results in string comparisons based on the sort order determined by the locale ID of the database where the string comparisons occur.

示例Example

此示例使用比较选项语句来设置默认字符串比较方法。在模块级别仅使用比较选项的语句。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.

' 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". 
© 2018 Microsoft