Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-24-2006, 10:58 PM   PM User | #1
voxecho
New Coder

 
Join Date: Jan 2006
Location: South Central, KS
Posts: 81
Thanks: 2
Thanked 2 Times in 2 Posts
voxecho is an unknown quantity at this point
isNull(vbNull) <> true Why?

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?
voxecho is offline   Reply With Quote
Old 04-25-2006, 03:40 AM   PM User | #2
BaldEagle
Regular Coder

 
Join Date: Apr 2005
Location: Lisbon, CT
Posts: 339
Thanks: 0
Thanked 0 Times in 0 Posts
BaldEagle is an unknown quantity at this point
Quote:
Originally Posted by voxecho
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
BaldEagle is offline   Reply With Quote
Old 04-25-2006, 03:51 AM   PM User | #3
voxecho
New Coder

 
Join Date: Jan 2006
Location: South Central, KS
Posts: 81
Thanks: 2
Thanked 2 Times in 2 Posts
voxecho is an unknown quantity at this point
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?
voxecho is offline   Reply With Quote
Old 04-25-2006, 02:43 PM   PM User | #4
BaldEagle
Regular Coder

 
Join Date: Apr 2005
Location: Lisbon, CT
Posts: 339
Thanks: 0
Thanked 0 Times in 0 Posts
BaldEagle is an unknown quantity at this point
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
BaldEagle is offline   Reply With Quote
Old 04-25-2006, 03:28 PM   PM User | #5
voxecho
New Coder

 
Join Date: Jan 2006
Location: South Central, KS
Posts: 81
Thanks: 2
Thanked 2 Times in 2 Posts
voxecho is an unknown quantity at this point
thanks, that's the result i needed
voxecho is offline   Reply With Quote
Old 04-25-2006, 03:36 PM   PM User | #6
degsy
Senior Coder

 
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
degsy is on a distinguished road
You can also use Null

Code:
<%
myvar = Null

If IsNull(myvar) Then
	Response.Write "myvar is null"
End If
%>
degsy is offline   Reply With Quote
Old 04-25-2006, 04:00 PM   PM User | #7
voxecho
New Coder

 
Join Date: Jan 2006
Location: South Central, KS
Posts: 81
Thanks: 2
Thanked 2 Times in 2 Posts
voxecho is an unknown quantity at this point
good BOG man! that's Brilliant!

hmmm, i thought i had tried that :\ color me sheepish

thanks

Quote:
Originally Posted by degsy
You can also use Null

Code:
<%
myvar = Null

If IsNull(myvar) Then
	Response.Write "myvar is null"
End If
%>
voxecho is offline   Reply With Quote
Old 04-25-2006, 04:24 PM   PM User | #8
BaldEagle
Regular Coder

 
Join Date: Apr 2005
Location: Lisbon, CT
Posts: 339
Thanks: 0
Thanked 0 Times in 0 Posts
BaldEagle is an unknown quantity at this point
Degsy. I knew about empty but not null.

BaldEagle
BaldEagle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:24 AM.


Advertisement
Log in to turn off these ads.