isnull说明指针为空,指针指到一个无效的位置,即对象不存在,
isempty说明指针指向一个有效位置,但是值为空
1、空字符串
例:
a)DimstrTmp
response.write(strTmp="")'返回true
b)response.write(str="")'返回true
c)DimstrTmp
strTmp=""
response.write(strTmp="")'返回true
没有赋值的变量ASP可以认为是空字符串或叫做零长度字符串。
2、IsEmpty()
如果变量未初始化或显式地设置为Empty,则函数IsEmpty返回True;
否则函数返回False。如果expression包含一个以上的变量,总返回False。
例:
a)DimstrTmp
Response.Write(IsEmpty(strTmp))'返回True
b)Response.Write(IsEmpty(str))'返回True
c)DimstrTmp
strTmp=Null
Response.Write(IsEmpty(strTmp))'返回Flase
d)DimstrTmpstrTmp=Empty
Response.Write(IsEmpty(strTmp))'返回True
e)DimstrTmp
strTmp=""
Response.Write(IsEmpty(strTmp))'返回Flase
没有赋值的变量也可以认为是Empty即空值
可以用isdate,isarray,isnumeric替代isempty进行测试a),b)两个例子,isnumeric也是返回True,isdate,isarray返回False
3.empty补充
dima,b,c,d,e,f,
a=0
b=0.0
c=""
d=false
e=empty
response.write(x=empty)'x请用a,b,c,d,e,f其中一个代替,返回都为true
response.write(isempty(x))'x请用a,b,c,d,e,f其中一个代替,除了e,f,其它返回都为false
4、IsNull()
Null值指出变量不包含有效数据。Null与Empty不同,后者指出变量未经初始化。Null与零长度字符串("")也不同,零长度字符串往往指的是空串。
使用IsNull函数可以判断表达式是否包含Null值。
例:
a)DimstrTmp
Response.Write(IsNull(strTmp))'返回False
b)Response.Write(IsNull(strTmp))'返回False注意这里strTmp是一个未经声明的变量
c)DimstrTmp
strTmp=Null
Response.Write(IsNull(strTmp))'返回True
d)DimstrTmp
strTmp=Empty
Response.Write(IsNull(strTmp))'返回False