请问access的vba代码中有一句Option Compare Database,这是什么用法

时间:2021-03-01 02:41:26
我查了一下access自带的帮助,原文如下:
Option Compare Database 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.

但是我仍然不太清楚“the sort order determined by the locale ID of the database ”究竟是什么用法。请高人指教。

2 个解决方案

#1


Option Compare Database 只能在 Microsoft Access 中使用。当需要字符串比较时,将根据数据库的区域 ID 确定的排序级别进行比较。


也就是说英文的  Z 在编码上小于 z ,那么中文的 "哈" 是否小于 "恩" 呢?这个就要靠 COMPARE 选项来决定了,主要是用于排序,也就是

if "哈" > "恩" then

的时候系统要知道如何判定哪个大哪个小

#2


该示例使用 Option Compare 语句设置缺省的字符串比较方法。Option Compare 语句只能在模块级使用。

'将字符串比较方法设为 Binary。
Option compare Binary     '这样,"AAA" 将小于 "aaa"。
'将字符串比较方法设为 Text。
Option compare Text    '这样,"AAA" 将等于 "aaa"。

#1


Option Compare Database 只能在 Microsoft Access 中使用。当需要字符串比较时,将根据数据库的区域 ID 确定的排序级别进行比较。


也就是说英文的  Z 在编码上小于 z ,那么中文的 "哈" 是否小于 "恩" 呢?这个就要靠 COMPARE 选项来决定了,主要是用于排序,也就是

if "哈" > "恩" then

的时候系统要知道如何判定哪个大哪个小

#2


该示例使用 Option Compare 语句设置缺省的字符串比较方法。Option Compare 语句只能在模块级使用。

'将字符串比较方法设为 Binary。
Option compare Binary     '这样,"AAA" 将小于 "aaa"。
'将字符串比较方法设为 Text。
Option compare Text    '这样,"AAA" 将等于 "aaa"。