Thursday, June 3, 2010

Verify whether given two strings are equal

Dim MyString1, MyString2
MyString1 = ("India")
MyString2 = ("India")
MyReturn = StrComp(MyString1, MyString2, vbTextCompare)
If (MyReturn = 1) Then
MsgBox MyReturn & " string1 is greater than string2"
ElseIf (MyReturn = 0) Then
MsgBox MyReturn & "string1 is equal to string2"
ElseIf (MyReturn = -1) Then
MsgBox MyReturn & "string1 is less than string2"
Else
MsgBox MyReturn & "string1 or string2 is Null"
End If

No comments: