首選如果 Len(myString) 0 然後結束如果 myString 那麼

檢查字串是否為零長度時,檢查字串的長度(而不是將字串與空字串進行比較)更好,更有效。

Const myString As String = vbNullString

'Prefer this method when checking if myString is a zero-length string
If Len(myString) = 0 Then
    Debug.Print "myString is zero-length"
End If

'Avoid using this method when checking if myString is a zero-length string
If myString = vbNullString Then
    Debug.Print "myString is zero-length"
End If