voxecho
04-24-2006, 10:58 PM
if i set a variable to vbNull it doesn't turn null... why is this?
i = 100
i = vbNull
i '// 1
isNull(vbNull) '// false
am i missing something?
BaldEagle
04-25-2006, 03:40 AM
if i set a variable to vbNull it doesn't turn null... why is this?
i = 100
i = vbNull
i '// 1
isNull(vbNull) '// false
am i missing something?
VBNull is a constant and should only be used with the VarType function.
When you do this:
i = vbNull you are assigning a 1 to i.
So:
isNull(i) would be false as well as isNull(vbNull) because vbNull is a constant = 1.
If you are having trouble grasping my explanation just google "vbnull" or "vbnull vbscript" and you will find many explanations.
BaldEagle
voxecho
04-25-2006, 03:51 AM
yes, i gathered all that. though it doesn't make sense to me to have it only for comparison. ah well.
how CAN you set a variable to null?
BaldEagle
04-25-2006, 02:43 PM
The only time I can think of it having a null would be when pulling data from a db with an empty field (never had data in it). You can set a var to Empty but IsNull will still return a false, however IsEmpty will return true.
myVar = Empty
Is there some particular reason you want Nulls?
BaldEagle
voxecho
04-25-2006, 03:28 PM
thanks, that's the result i needed :D
degsy
04-25-2006, 03:36 PM
You can also use Null
<%
myvar = Null
If IsNull(myvar) Then
Response.Write "myvar is null"
End If
%>
voxecho
04-25-2006, 04:00 PM
good BOG man! that's Brilliant!
hmmm, i thought i had tried that :\ color me sheepish :p
thanks
You can also use Null
<%
myvar = Null
If IsNull(myvar) Then
Response.Write "myvar is null"
End If
%>
BaldEagle
04-25-2006, 04:24 PM
:thumbsup: Degsy. I knew about empty but not null.
BaldEagle