Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking variables containing nothing

Status
Not open for further replies.

Hylsan

Programmer
Mar 20, 2002
43
SE
Hi
Ok it might be a wierd subject but i couldnt come up with a better.

I have a integer that i wanna check if it has any value. When looking at it with a watch it contains "nothing" but how do i write that in the code?
This is how it looks now but aint working;
Code:
if -1 <> iVariable then
  ...
end if

Hope you understand what i mean, and that you can help me.

Thanks in advance!

/Hylsan
 
Code:
if iVariable is Nothing
'Your Code
endif


Sweep
...if it works dont mess with it
 
Hylsan,

To do this use the is nothing command in the so it would look like this.

if iVariable is Nothing then
...
end if
HTH,
Bueller
 
Thanks both of you!
It works like a charm now :)

/Hylsan
 
Wait a minute. A variable defined As Integer can never be Nothing.

Now if you have Option Strict Off (BAD Idea) and are boxing and unboxing values with objects (another BAD idea), it is possible to have an integer "boxed" inside an object.

Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top