title: ByRef and ByVal in VBScript
body: <p>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 parameter is passed !</p>
  
  <p>Here is an example :</p>
  
  <pre><code>Sub IncrementByRef(ByRef Value)
     Value = Value + 1
  End Sub
  
  Sub IncrementByVal(ByVal Value)
     Value = Value + 1
  End Sub
  
  Dim Num
  Num = 10
  WScript.Echo "Num : " &amp; Num
  IncrementByRef(Num) : WScript.Echo "IncrementByRef(Num) : " &amp; Num
  IncrementByRef Num  : WScript.Echo "IncrementByRef Num : " &amp; Num
  IncrementByVal(Num) : WScript.Echo "IncrementByVal(Num) : " &amp; Num
  IncrementByVal Num  : WScript.Echo "IncrementByVal Num : " &amp; Num
  </code></pre>
  
  <p>And here is the output :</p>
  
  <pre><code>U:\&gt;cscript //nologo byrefbyval.vbs
  Num : 10
  IncrementByRef(Num) : 10
  IncrementByRef Num : 11
  IncrementByVal(Num) : 11
  IncrementByVal Num : 11
  
  U:\&gt;
  </code></pre>
  
  <p>When specifying the the parameters are passed ByVal, it works as expected, no matter the way the procedure is called.
  But when specifying the parameters are passed ByRef, it will work as expected if calling the procedure this way :</p>
  
  <pre><code>IncrementByRef Num
  </code></pre>
  
  <p>but not this way :</p>
  
  <pre><code>IncrementByRef(Num)
  </code></pre>
  
  <p>This seems weird to me. Is there a way to make sure the parameters are passed ByRef, no matter how the procedure is called ?</p>