By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,182 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,182 IT Pros & Developers. It's quick & easy.

IsNull bug in ASP?

P: n/a
I am getting wierd behaviour with IsNull in ASP. I am
passing a string (which may be null) to a function. When
the string is null, IsNull seems to return false the
first time it is called, then True the second time. The
code follows, am I doing something wrong, or is this a
bug?

Bob

function unquote(st) 'make database string suitable for
output
'#################
Dim test, test2
test = IsNull(st)
test2 = IsNull(st)
if test then
unquote=st
exit function
end if
response.write("In unquote st = " & st & "; isNull(st)
=" & IsNull(st) & "; " & test & "; " & test2 & "<br>")
'if st is null, test is false, but test2 is true
st = replace(st, "&", "&")
st = replace(st, "'", "'")
st = replace(st, """, chr(34))
st = replace(st, "<br>", chr(13) & chr(10))
unquote = st
end function

Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Bob Cottis wrote on 15 okt 2003 in
microsoft.public.inetserver.asp.general:
I am
passing a string (which may be null)


There is no such thing as a "null string" in vbs.

st = null is not a atring, so you cannot do replaces on it.

st = "" is an empty string, not a null, so:
isnull("") gives true

Perhaps you could, dependng on your application,
change the null variable to an empty string:

if isnull(st) then st = ""

?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2

P: n/a
A much safer method than relying on null values (which can cause havoc with
outputing a recordset, for instance):

If Len(Trim(MyPossiblyNullValue & " ")) = 0
'--- stuff here
End If

- Wm
--
William Morris
Product Development, Seritas LLC

"Bob Cottis" <an*******@discussions.microsoft.com> wrote in message
news:2b*****************************@phx.gbl...
I am getting wierd behaviour with IsNull in ASP. I am
passing a string (which may be null) to a function. When
the string is null, IsNull seems to return false the
first time it is called, then True the second time. The
code follows, am I doing something wrong, or is this a
bug?

Bob

function unquote(st) 'make database string suitable for
output
'#################
Dim test, test2
test = IsNull(st)
test2 = IsNull(st)
if test then
unquote=st
exit function
end if
response.write("In unquote st = " & st & "; isNull(st)
=" & IsNull(st) & "; " & test & "; " & test2 & "<br>")
'if st is null, test is false, but test2 is true
st = replace(st, "&", "&")
st = replace(st, "'", "'")
st = replace(st, """, chr(34))
st = replace(st, "<br>", chr(13) & chr(10))
unquote = st
end function

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.