Laphan wrote:
Hi all
In my functions I'm using a double-check all the time to trap if a
value has nothing in it and my question is do I need this
double-check.
My check line is:
IF IsNull(xxx) OR LEN(xxx) = 0 THEN
blah blah
ELSE
blah blah
END IF
xxx is usually an array built up of data from an ADO recordset so will
LEN(xxx) = 0 cover my zero values or do I still need the IsNull check
as well?
To answer the question in the subject line:
No
IsNull("") will return false
IsNull(Null) will return true
(len(Null)=0) will return Null
(len("")=0) will return true
However, you can shorten your statement by taking advantage of a strange
behavior in vb/vbscript
: concatenating a string to a null will result in a
string, NOT in a null. This is not the expected behavior because most other
operations involving Null will result in Null (1 + null results in null).
So:
IF len(xxx & "") = 0 THEN
will serve your purpose
The answer may not be the same in other languages.
However, if xxx should be an array, then you need to use IsArray to test
whether or not it is an array. If you mean that you want to test a
particular element in the array, i.e., xxx(0), then yes, use len(xxx(0) &
"")=0. Only use IsNull if you want to specifically check for Null.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.