469,632 Members | 1,632 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

IsNull bug in ASP?

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
2 14074
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
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.

Similar topics

2 posts views Thread by Trev | last post: by
4 posts views Thread by Paul Spratley | last post: by
2 posts views Thread by Raoul Watson | last post: by
16 posts views Thread by madeleine | last post: by
4 posts views Thread by jimm.sander | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.