O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Passing Value and Reference Parameters

You might wish to pass a value type to a procedure as a reference with the keyword ByRef. In this case, the data itself is not copied to the stack, but only a pointer to the corresponding storage location in the stack. Changes to other data within the procedure are directly reflected in the original variable. Changing the reference parameters within the called procedure changes the variable value in the calling program, as well. Here’s an example:

Dim ValueType1 as New NumberSystems(10) TakesValueType(ValueType1) Console.WriteLine(ValueType1.Value) Dim ValueType2 as NumberSystems = ValueType1 ValueType2.Value = 50 Console.WriteLine(ValueType1.Value) . . . Sub TakesValueType(ByRef ValueType As NumberSystems) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required