VB 文字列の比較

  • String型は、宣言した段階では、Nothingが設定されている。
  • = 演算子は、Nothingと ”” は 等価 とみなす

 Dim sss As String =""

If sss = String.Empty Then

これは trueになる

Dim sss As String

If sss = String.Empty Then

これも trueになる


 Nothingかどうかの判定

If  sss Is Nothing Then

または

If  IsNothing(sss) Then

 

Is Nothingがおすすめだそうだ

VisualBasic名前空間のIsNothing()と、.NETのIs Nothing速度比較 - misc.log

IsNothingと Is Nothingの違い: 放課後のVB中学校