How to use IsNullOrEmpty in VB.NET?
102,329
Solution 1
IsNullOrEmpty is 'shared' so you should use it that way:
If String.IsNullOrEmpty(strTest) Then
Solution 2
You can actually just compare to an empty string:
If strTest = "" Then
MessageBox.Show("NULL OR EMPTY")
End If
Solution 3
String.IsNullOrEmpty is a shared (or static, in C#) method.
Dim strTest As String
If (String.IsNullOrEmpty(strTest)) Then
MessageBox.Show("NULL OR EMPTY")
End if
Author by
CJ7
Updated on July 09, 2022Comments
-
CJ7 almost 2 years
Why doesn't the following compile in VB.NET?
Dim strTest As String If (strTest.IsNullOrEmpty) Then MessageBox.Show("NULL OR EMPTY") End if