·您的位置: 首页 » 资源教程 » 编程开发 » ASP » 不要节约使用变量

不要节约使用变量

类别: ASP教程  评论数:0 总得分:0
Now, you might be wondering, what does he mean, Don\'t skimp on the variables? Well, often times it is more
efficient to use variables to store results from ADO queries or from objects, and then reference the
variable as opposed to continuously referencing the object.

For example, you could do this:


If Request.QueryString("Name") = "Frank" Then
...
End If

If Request.QueryString("Name") = "Steve" Then
...
End If

Response.Write("Your name is " & Request.QueryString("Name"))
Each time you use the Request object, ASP has to go read the QueryString variable name. You can reduce
this to having to just read this once by doing the following:


Dim strName
strName = Request.QueryString("Name")

If strName = "Frank" Then
...
End If

If strName = "Steve" Then
...
End If

Response.Write("Your name is " & strName)
Plus, I personally think the above scenario is easier to read. It\'s easier, I think, to mentally associate
strName to be the user\'s name as opposed to associating Request.QueryString("Name") as the user\'s name.
Just my two cents, though!
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1