Mega Code Archive

 
Categories / VB.Net / Data Types
 

Compares substrings ignoring or honoring their case

Imports System Imports Microsoft.VisualBasic Class Sample    Public Shared Sub Main()       Dim str1 As [String] = "MACHINE"       Dim str2 As [String] = "machine"       Dim str As [String]       Dim result As Integer       Console.WriteLine("Ignore case:")       result = [String].Compare(str1, 2, str2, 2, 2, True)       str = IIf(result < 0, "less than", IIf(result > 0, "greater than", "equal to"))       Console.Write("{0} ", str)       Console.WriteLine("Honor case:")       result = [String].Compare(str1, 2, str2, 2, 2, False)       str = IIf(result < 0, "less than", IIf(result > 0, "greater than", "equal to"))       Console.Write("{0} ", str)    End Sub End Class