什么是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
作者:terry,如若转载,请注明出处:https://www.web176.com/vbscript/1107.html