日期:2008-07-23  浏览次数:20948 次

Aiyiweb.Com提示:众所周知:asp(VBS)是不区分大小写的,但是你要理解这句话的意思,请看下面实.

众所周知:asp(VBS)是不区分大小写的,但是你要理解这句话的意思,请看下面实例

Test.asp
<%
Dim aName
If Request.QueryString("name") <> "" Then
        aName = Trim(Request.QueryString("name"))
        Select Case aName
                Case "new"
                        Response.Write "New"
                        Response.End
                Case "top"
                        Response.Write "Top"
                        Response.End
                Case Else
                        Response.Write "Other"
                        Response.End
        End Select
Else
        Response.Write "No Value"
        Response.End
End If
%>
如果你执行http://localhost/test.asp?name=new,它会输出:New
而如果执行http://localhost/test.asp?name=New,它却输出:Other


所以确保不出现意想不到的错误,在select  Case中先将条件转成大/小写,这样
<%
Dim aName
If Request.QueryString("name") <> "" Then
        aName = LCase(Request.QueryString("name"))
        Select Case aName
                Case "new"
                        Response.Write "New"
                        Response.End
                Case "top"
                        Response.Write "Top"
                        Response.End
                Case Else
                        Response.Write "Other"
                   &nbs