Hey I'm trying to check if a variable has a value assigned or not.
Dim var as Integer
If var=Null then
...
else
...
end if
But it seems that Null doesn't exist, and 'Nothing' isn't quite the same as for an integer Nothing=0.
Any ideas? thanks.
Printable View
Hey I'm trying to check if a variable has a value assigned or not.
Dim var as Integer
If var=Null then
...
else
...
end if
But it seems that Null doesn't exist, and 'Nothing' isn't quite the same as for an integer Nothing=0.
Any ideas? thanks.
I believe an integer is automatically 0 when not initiated, but wouldn't null just be an empty set ("")?
Nothing is when the object hasn't been initialised i.e.
A string is always an empty string, which is not nothing. An Integer or any variation of it will always be 0 is it hasn't been set.Code:Dim NewClass as Class1
If NewClass Is Nothing Then
'NewClass is Nothing because it hasn't been initialized yet.
End If
'Whereas
Dim NewClass as New Class1
If NewClass Is Nothing Then
Else
'NewClass is not Nothing because it has been initialized.
End If