ByRef and ByVal in VBScript

后端 未结 6 2059
梦如初夏
梦如初夏 2020-11-28 08:24

I\'m facing something weird in VBScript. When writing a procedure where I want the parameter to be passed by reference, the way of calling this procedure changes the way the

6条回答
  •  失恋的感觉
    2020-11-28 08:38

    It's a feature, not a bug:
    http://msdn.microsoft.com/en-us/library/ee478101.aspx

    A ByRef parameter is passed by value if the argument is enclosed in parentheses and the parentheses do not apply to the argument list.

    The parentheses apply to the argument list if one of the following is true:

    • The statement is a function call that has an assignment to the returned value.

    • The statement uses the Call keyword. (The Call keyword can optionally be used for a subroutine call, or for a function call without an assignment.)

    So try using the Call keyword or having it return a value.

提交回复
热议问题