Declaring NULL

ICeMaN_179

Newcomer
Joined
Oct 18, 2002
Messages
7
Location
UK
i am using

Visual Basic:
is null

in my code and i get a compile error and the debugger says that NULL needs to be declared, what does this need to be declared as ?

dim NULL as ???
 
In VB.NET, to check if a class is not inialized, use Is Nothing:

Visual Basic:
If myObj Is Nothing Then
  ' Moo
End If
 
would it be: (this didn't work for me)

Visual Basic:
if TXTInput is nothing then
msgbox "Please enter text !!", msgstyle.question, "Error"
else
exit sub
end if
 
Try this:
Visual Basic:
If TXTInput.Text = "" Then
    msgbox "Please enter text !!", msgboxstyle.question, "Error"
End If
Orbity
 
Why? Null, Nothing and "" are all different things, and so can't be
interchanged. "" is a string, while Nothing is.... nothing. It's the
lack of anything in the Text object. Stick with "". If you want to do
it a different way, you could use If txtInput.Text.Length = 0 Then. :-\
 
I know in C# you can use string.Empty (or String.Empty). The fastest method will always be to check the length, VolteFace's last comment.
If txtInput.Text.Length = 0 Then

Strings are objects in .NET and contain a header which contains, among other things, the length. It's faster to compare that a known number than to check for "" (or even string.Empty).

-Nerseus
 
Back
Top