how to compare 2 strings in in VB .Net simple code
code:
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim str1 As String
Dim str2 As String
str1 = "vb.net"
str2 = "VB.NET"
Dim result As Integer
result = String.Compare(str1, str2)
MsgBox(result)
result = String.Compare(str1, str2, True) 'true is case insensitive
MsgBox(result)
End Sub
End Class
result is Integer : returns less than zero, zero or greater than zero.
Less than zero : str1 is less than str2.
Zero : str1 is equal to str2.
Greater than zero : str1 is grater than str2.
When you run this program first you get -1 in message box and then 0