1

I have an asp file with a lot of constants (constants.inc). Into asp page:

<!-- #Include file="../../constants.INC" -->

....

<script language="vbscript" type="text/vbscript" src="../scripts/scrmot.vbs"></script>

....

Into scrmot.vbs I want to do next:

Function validChars
  Dim carval
  carval = <%=scarVal%> 'scarVal is a constant defined in constants.INC
  ....
End Function

but that crashes! The entire .vbs file doesn't charge because that instruction get error. How can assign the constant asp scarVal to a vbscript variable carval?

4

1 回答 1

2

您不能这样做,因为 .vbs 文件不是由 ASP 引擎呈现的。

您可以做的是通过在 .asp 页面本身中包含此类代码,将您需要的所有常量传递给客户端:

<script language="vbscript" type="text/vbscript">
    Const scarVal = "<%=scarVal%>"
</script>

并在函数中使用客户端常量:

Function validChars
    Dim carval
    carval = scarVal
    ....
End Function
于 2013-07-07T08:42:32.447 回答