posts - 124,  comments - 29,  trackbacks - 0
 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 01
 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 819282048209
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 天书 阅读(346) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2008年9月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(5)

随笔档案

文章分类

文章档案

好友的Bolg

搜索

  •  

最新评论

阅读排行榜

评论排行榜