Comparing

A < B < a < b


Case Sensitive

This method is overloaded and is case sensitive by default.

System.String.Compare(sText1, sText2) 

sText1 < sText2

System.String.Compare("aaa", "bbb") = -1 (less than zero) 

sText1 > sText2

System.String.Compare("bbb", "aaa") = 1 (greater than zero) 

sText1 = sText2

System.String.Compare("aaa", "aaa") = 0 

sText1 <> sText2

System.String.Compare("aaa", "AAA") = 

Case InSensitive

It is possible to compare strings and ignore the case

System.String.Compare(sText1, sText2, True) 

sText1 = sText2

System.String.Compare("aaa", "AAA", True) = 0 


Testing For Equality

There are two ways you can test to see if two strings are equal.
You can use the Equals method from one of the strings

Dim sFirstName As String 
Dim sLastName As String
bequal = sFirstName.Equals(sLastName)

Or you can pass both the strings to the String class method.

Dim sFirstName As String 
Dim sLastName As String
bequal = System.String.Equals(FirstName, sLastName)


© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext