What is the syntax to compare strings?

StrComp (string1, string2, compare)
‘both string1, string2 are mandatory parameters
‘compare – 0 for binary comparison or 1 for textual comparison; optional parameter with 0 being default
‘please note, an integer value is returned

‘If str1 < str2 then -1
'If str1 > str2 then 1
'If str1 = str2 then 0
‘examples
MsgBox (StrComp("Hello", "Hello")) '0
MsgBox (StrComp("hello", "HELLO")) '1
MsgBox (StrComp("HELLO", "hello")) '-1
MsgBox (StrComp("Hello", "Goodbye")) '-1

 

Advertisements