{}

我们的品牌

欢迎访问施耐德电气网站

欢迎访问我们的网站。
搜索常见问题解答
Citect字符串如何比较?
问题描述:
Citect字符串如何比较?

所属产品线:
AVEVA™ Plant SCADA

解决方法:

CITECT 字符串比较使用StrComp()函数,需要注意的是,字符串比较有两种方式:1 二进制方式比较(转换成ANSI编码进行比较);2 文本模式比较(字符比较,不区分大小写)。使用此函数比较之前要声明比较方式,详见如下示例:

Example

Option Compare Binary    
Dim vntResult as Variant
vntResult = ("CitectVBA rules!", "Citectvba Rules!") 
' returns 1 (strings unequal)

Example

Option Compare Text    
Dim vntResult as Variant
vntResult = ("CitectVBA rules!", "Citectvba Rules!") 
' returns 0 (strings equal)

定义成STRING类型时是采用转换成ANSI编码进行比较的,详见如下示例:

Return Value

Returns a variant containing an integer data type indicating the result of the string compare:

  • Returns -1 where String1 is less than String2.

  • Returns 0 where String1 is equal to String2.

  • Returns 1 where String1 is greater than String2.

  • Returns Null where String1 or String2s Null.

Example

Dim strTest1 as String
Dim strTest2 as String
Dim strTest3 as String
Dim vntComp
strTest1 = "ABCD"
strTest2 = "abcd"
strTest3 = NULL
vntComp = StrComp(strTest1, strTest2) ' Returns -1 (less than) 
vntComp = StrComp(strTest1, strTest1) ' Returns 0 (equal to) 
vntComp = StrComp(strTest2, strTest1) ' Returns 1 (greater than) 
vntComp = StrComp(strTest1, strTest3) ' Returns NULL (strTest3 is NULL)



是否有帮助?

探索更多
范围:
探索更多
范围: