ASP教程:ASP是不区分大小写

2008-02-20 23:21:20  来源:网页教学网收集整理 

WebjxCom提示:众所周知: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"
                        Response.End
        End Select
Else
        Response.Write "No Value"
        Response.End
End If
%>

总之,要理解VB不区分大小写的意思是什么...

对象名、属性名、变量名等本身构成的语法不区分大小写
然而属性值、变量值区分大小写,也就是说:"A"="a"为false
更多