DIAdem Help

Method: StrComp for VBS

  • Updated2024-09-12
  • 1 minute(s) read

Method: StrComp for VBS

Compares two texts.

vStrComp = Object.StrComp(string1, string2, [compare])
ObjectVBS
Object with this method. You do not need to specify this object.
string1Variant
Specifies a text.
string2Variant
Specifies a text.
[compare]Variant
Specifies the type of comparison. Possible settings are vbBinaryCompare and vbTextCompare. If you do not specify compare, the Strcomp method performs a binary comparison.
vStrCompVariant
Receives the result of the text comparison. Possible return values:
ConditionReturn value
string1 is smaller than string2-1
string1 is equal to string20
string1 is greater than string21
string1 or string2 is NullNull

The following example compares two texts:

Dim MyStr1, MyStr2, MyComp
MyStr1 = "ABCD"
MyStr2 = "abcd"
MyComp = StrComp(MyStr1, MyStr2, vbTextCompare) ' Returns 0
Call MsgBox(MyComp)
MyComp = StrComp(MyStr1, MyStr2, vbBinaryCompare) ' Returns -1
Call MsgBox(MyComp)

See Also

Objects Overview

Related Topics

Filter | InStr | InStrB | InStrRev | Join | LCase | Left | LeftB | Len | LenB | LTrim | Mid | MidB | Replace | Right | RightB | RTrim | Space | Split | StrComp | String | StrReverse | Trim | UCase

Log in to get a better experience