Declaring NULL

ICeMaN_179

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

Code:
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:

Code:
If myObj Is Nothing Then
   Moo
End If
 
would it be: (this didnt work for me)

Code:
if TXTInput is nothing then
msgbox "Please enter text !!", msgstyle.question, "Error"
else
exit sub
end if
 
Try this:
Code:
If TXTInput.Text = "" Then
    msgbox "Please enter text !!", msgboxstyle.question, "Error"
End If
Orbity
 
Why? Null, Nothing and "" are all different things, and so cant be
interchanged. "" is a string, while Nothing is.... nothing. Its 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, VolteFaces last comment.
If txtInput.Text.Length = 0 Then

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

-Nerseus
 
Nerseus is correct, never compare a string to "", always check the length.
 
Back
Top