VBScript ByVal 参数
什么是 ByVal 参数?
如果指定了 ByVal,则在调用函数或过程时参数将作为按值发送。
示例
<!DOCTYPE html>
<html>
<body>
<script language = "vbscript" type = "text/vbscript">
Function fnadd(Byval num1, Byval num2)
num1 = 4
num2 = 5
End Function
Dim x,y
x = 6
y = 4
res = fnadd(x,y)
document.write("The value of x is " & x & "<br />")
document.write("The value of y is " & y & "<br />")
</script>
</body>
</html>
上述函数采用参数 x 和 y 作为值。 因此,执行该函数后,这些值不会发生变化。
如果上述函数保存为.html并在IE中执行,输出将如下 −
The value of x is 6 The value of y is 4

vbscript_procedures.html