文字列(String)が空の文字列かを調べるに方法にて説明します。
等値演算子による比較
Dim s As String = ""
If s Is Nothing Then
MessageBox.Show("文字列はNULLです")
End If
If s = "" Then
MessageBox.Show("文字列は空です")
End If
If s = String.Empty Then
MessageBox.Show("文字列はEmptyです")
End If
Equals メソッドによる比較
Dim s As String = ""
If s.Equals("") Then
MessageBox.Show("文字列は空です")
End If
If s.Equals(String.Empty) Then
MessageBox.Show("文字列はEmptyです")
End If
Nothing (NULL) か比較
Dim s As String = ""
If s Is Nothing Then
MessageBox.Show("文字列はNULLです")
End If
※文字列は
Dim s As String
Dim s As String = “”
Dim s As String = Nothing
※以上3つとも値がことなりますので注意