[VB.NET]関係演算子を使って文字列の比較サンプル
書式
Dim 変数文字列1 As String =値1
Dim 変数文字列2 As String =値2
変数文字列1 > 変数文字列2
関係演算子を用いて文字列同士の大小関係を比較します
使用例
Module Module1
Public Sub Main()
Dim strA As String = "study"
Dim strB As String = "skill"
If strA < strB Then
Console.WriteLine("strA < strB 11")
ElseIf strA > strB Then
Console.WriteLine("strA > strB 22")
Else
Console.WriteLine("strA = strB 33")
End If
Console.ReadKey()
End Sub
End Module
Module Module1
Public Sub Main()
Dim strA As String = "study"
Dim strB As String = "skill"
If strA < strB Then
Console.WriteLine("strA < strB 11")
ElseIf strA > strB Then
Console.WriteLine("strA > strB 22")
Else
Console.WriteLine("strA = strB 33")
End If
Console.ReadKey()
End Sub
End Module
Module Module1 Public Sub Main() Dim strA As String = "study" Dim strB As String = "skill" If strA < strB Then Console.WriteLine("strA < strB 11") ElseIf strA > strB Then Console.WriteLine("strA > strB 22") Else Console.WriteLine("strA = strB 33") End If Console.ReadKey() End Sub End Module
実行結果
strA > strB 22