Compare strings
This code shows how to compare two strings.
Private Sub CompareString()
Dim strString1 As String
Dim strString2 As String
Dim intI, intJ As Integer
strString1 = "test"
strString2 = "test"
intI = 1
intJ = 1
While strString1.Length >= intI Or strString2.Length >= intJ
'If the length of any of the string is
'greater than 0 than compare both the strings
If Mid$(strString1, intI, 1) = Mid$(strString2, intJ, 1) Then
'Compare each and every character of the string.
'If the charater matches then increment both
'intI,intJ by 1.
intI = intI + 1
intJ = intJ + 1
Else
'If any of the character does not match
'then the strings are not equal.
MessageBox.Show("Strings are not equal")
Exit Sub
End If
End While
MessageBox.Show("Strings are equal")
End Sub
This is enough Buddy.
Dim str As String = "test"
Dim str2 As String = "test"
Dim st As Integer = StrComp(str, str2)
If st=0 Then
MessageBox.Show("Strings are equal")
Else
MessageBox.Show("Strings are not equal")
End if