1Public Function IsBlank(ByRef TempVar)
2 'by default, assume it's not blank
3 IsBlank = False
4 'now check by variable type
5 Select Case VarType(TempVar)
6 'Empty & Null
7 Case 0, 1
8 IsBlank = True
9 'String
10 Case 8
11 If Len(TempVar) = 0 Then
12 IsBlank = True
13 End If
14 'Object
15 Case 9
16 tmpType = TypeName(TempVar)
17 If (tmpType = "Nothing") Or (tmpType = "Empty") Then
18 IsBlank = True
19 End If
20 'Array
21 Case 8192, 8204, 8209
22 'does it have at least one element?
23 If UBound(TempVar) = -1 Then
24 IsBlank = True
25 End If
26 End Select
判空函数应用
1<%
2'关键字从Title里面选
3classid = request("classid")
4key = request("keyword")
5if IsBlank(classid) and IsBlank(key) then
6 sql = "select Resource.ID, Title, ClassID, CName from Resource, Class where Resource.ClassID = Class.ID "
7else
8 sql = "select Resource.ID, Title, ClassID, CName from Resource, Class where Resource.ClassID = Class.ID "
9 if CINT(classid) = -1 then
10 sql = sql
11
12 else
13 sql = sql + " and ClassID = " & classid
14
15 end if
16
17 if len(key) > 0 Then
18 sql = sql & " and Title like '%"& key &"%' "
19
20 else
21 sql= sql
22
23 end if
24end if
25
26set rs = server.createobject("adodb.recordset")
27%>
posted on 2008-06-08 21:58
天书 阅读(357)
评论(0) 编辑 收藏 引用