Com*_*tix 0 vbscript asp-classic
我只是想知道是否有可能取消变量.
想象一下,这是我在ASP页面中使用的#include文件
Dim MyVar
MyVar = "Hello World"
Response.write(MyVar)
'From now on I can not use Dim MyVar anymore as it throws an error
'I have tried
MyVar = Nothing
Set MyVar = Nothing
'But again, when you do
Dim MyVar
'It throws an error.
原因是我不能每页多次使用相同的#INCLUDE文件.是的,我喜欢使用Option Explicit,因为它可以帮助我保持代码清洁.
*)编辑:我发现它并不像我想的那么清晰.
想象一下这是一个"include.asp"
<%
Dim A
A=1
Response.Cookie("beer")=A
%>
现在的asp页面:
<!--#include file="include.asp"-->
<%
'Now: I do not see whats in include above and I want to use variable A
Dim A
'And I get an error
'I also cannot use the same include again:
%>
<!--#include file="include.asp"-->
你明白我的意思吗?如果我能够在Include结尾处删除A变量,问题就会解决.
没有办法"UnDim"变量.幸运的是,你也不需要那个.
每当你尝试在同一范围内声明一个变量两次时,你就已经犯了一个错误.认为运行时没有让你有用.
解决方案:
| 归档时间: | 
 | 
| 查看次数: | 2396 次 | 
| 最近记录: |