Compares two Strings using the specified comparison options and culture-specific information
Imports System.Globalization
Public Module Example
Public Sub Main()
Dim string1 As String = "brother"
Dim string2 As String = "Brother"
Dim relation As String
Dim result As Integer
result = String.Compare(string1, string2,New CultureInfo("en-US"), CompareOptions.None)
If result > 0 Then
Console.WriteLine("comes after")
ElseIf result = 0 Then
Console.WriteLine("is the same as")
Else
Console.WriteLine("comes before")
End If
result = String.Compare(string1, string2,New CultureInfo("en-US"), CompareOptions.IgnoreCase)
If result > 0 Then
Console.WriteLine("comes after")
ElseIf result = 0 Then
Console.WriteLine("is the same as")
Else
Console.WriteLine("comes before")
End If
result = String.CompareOrdinal(string1, string2)
If result > 0 Then
Console.WriteLine("comes after")
ElseIf result = 0 Then
Console.WriteLine("is the same as")
Else
Console.WriteLine("comes before")
End If
End Sub
End Module
Related examples in the same category