
常用软件类: |
|杀毒安全 | |联络聊天 | |网络软件 | |多媒体类 | |系统工具 | |图形图像 | |系统工具 | |应用软件 | |行业软件 |
开发设计类: |
|动画制作 | |图像处理 | |3D设计 | |操作系统 | |站长学院 | |网络相关 | |WEB设计 | |数据库类 | |程序开发 |
转换
当你开始使用和VB差不多的语言的时候,你会犯一些简单的错误,比如比较整型的512和串512。如果你认识到前一个512和后一个512是不一样的,你可以想想为什么给出的脚本不能正常工作。
假想一下,你传送一个文件的ID到ASP脚本中,使用Request.QueryString,你会确定这个文件的ID就是用户想要编辑的。你需要从数据库中为记录输入一些信息并将它们显示在屏幕上。数据库中的ID和整型差不多,特别地,如果你在那个区域使用了AutoNumber性能。你输入的ID事实上是一个串。因此,这两个永远不可能匹配除非你转换成相同的类型。
Request.QueryString:
使用FileSystemObject, 你可以测试一个文本—比如, *.html, *.asp, *.inc., *.gif—或者目录的存在。如果文件存在,你可以想要一连串的时间发生。如果文件不存在,你可能需要其他的事件发生,使用下面的代码: <%
sPath="/profiles/" & strFileName & ".asp"
sFile=Server.MapPath(sPath)
Set fe=Server.CreateObject("Scripting.FileSystemObject")
if fe.FileExists(sFile) THEN
'do something
Response.Write "Yeah! I found it!."
Response.Write "You can access that file by "
Response.Write "<A HREF=""" & sPath & """>Clicking Here</A>."
else
'do something
Response.Write "Sorry. The requested file does not exist."
end if
%>
为了简单的测试你这个文件,添加脚本到最上面:
strFileName = "name"
' First assign the name of a file you have to this variable.
' strFileName holds just the name, not the extension or the path.
' Make sure you change the path for sPath to the virtual directory your file is in
' Run the script.
' Then come back and change the strFileName variable to the name of a file
' you do NOT have.
' Run the script.
改变被输入的代码为一个整型是非常容易的并且可以让你以后的工作变得容易一点,样本的格式是这样的:
<%
dim intUserID intUserID = Request.QueryString("userID")
intUserID = CInt(intUserID)
' intUserID is now an integer.
%>
你同样也可以注释你的ASP代码并使用它们。
注释代码
在ASP中,一个脚本在它被发送到浏览器之前就被执行,所以,你不需要使用普通的HTML注释标签来从旧的浏览器隐藏脚本。事实上,你的脚本不会在HTML源中显示,因为那个源代码被浏览器交出去了,所以,旧的浏览器不会突然的发射任何代码到屏幕上。
你可能想要注释来注释你的ASP脚本,在VB脚本中,你可以使用省略符来记录注释: