Why doesn't the following compile in VB.NET?
Dim strTest As String
If (strTest.IsNullOrEmpty) Then
MessageBox.Show("NULL OR EMPTY")
End if
You can actually just compare to an empty string:
If strTest = "" Then
MessageBox.Show("NULL OR EMPTY")
End If
strTest is nothing? IsNullOrEmpty explicitly contains a check whether strTest is nothing. Your statement does not check this.Nothing as identical "" when doing string comparisons (and in other places too).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
strTest without setting a value (which could be a mistake), so it is always Nothing. You can get around it by using Dim strTest As String = Nothing e.g. to explicitly set it to Nothing.Nothing anyway. Why should I have to explicitly set it to Nothing - doesn't make any sense!Nothing anyway, but since you didn't explicitly tell the compiler so, it just warns you that it could be a bug in your code (hence it's just a warning, not an error). Note that you can disable those warnings, but I would not recommend doing so.
Argument not specified for parameter 'value' of 'Public Shared Function IsNullOrEmpty(value As String) As Boolean'., so you could guess it's because you didn't specify an argument for the parametervalueof that method. What I want to say is that (most of the time) the compiler will tell you what's wrong with your code.