Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


COM, on the other hand, supports both "pass-by-value" (or "byval") and "pass-by-reference" (or "byref").  "Byval" is sometime referred to as an "in" parameter, and "byref" is sometimes referred to as an "in/out" parameter, reflecting the direction the data is flowing.  When you call a method that accepts a "pass-by-reference" parameter, the method can modify the parameter value, and this will be reflected in the calling scope. 

Byref argument passing was always a favorite of C/C++ programmers, who often use the result of a method to pass exception information.  It was the default way to pass values in versions of Visual Basic through 6.  With the advent of modern try/catch exception handling, modifying values inside a method is generally considered bad programming practice.  Visual Basic (and COM) still supports byref, but byval is now defined as the default setting.  You should not have to deal with byref parameters often, especially when dealing with APIs that are designed for scripting. That doesn't mean it will never happen, though.