Print Page | Close Window

testing for a null variable.

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=183
Printed Date: 28 March 2026 at 10:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: testing for a null variable.
Posted By: Nathan
Subject: testing for a null variable.
Date Posted: 15 February 2003 at 12:55am

I use a chat script for my site. If no one is chatting, then one variable has a null value. Of course if I try to reference the variable (which I do to display how many are chatting) I get a script crash. How can I 'test' if a variable is null first?

I assume:

if chatters=null then

else

end if

 

(but this does not seem to work)

Cheers

Nathan




Replies:
Posted By: MadDog
Date Posted: 15 February 2003 at 12:58am

Do something like this... (i believe the IsNull() will work)

If IsNull(chatters) = True Then

Else

End If



-------------
http://www.iportalx.net" rel="nofollow">


Posted By: Nathan
Date Posted: 17 February 2003 at 2:19pm
Thanks MD, I'll give it a go - looks like it will work.


Posted By: MorningZ
Date Posted: 17 February 2003 at 2:44pm
i always do it this way

if (chatter & "") = ""
   'is empty
else
   isn't
end if

then there is no seperate check needed for NULL or
"empty string"

-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net