Pass value by reference : Pass by Reference « Class Module « VB.Net Tutorial






Option Strict On
 Imports System

 Module Module1

    Sub Main( )
       Dim theVariable As Integer = 5

       Console.WriteLine("In Run. theVariable: {0}",theVariable)

       Doubler(theVariable)

       Console.WriteLine("Back in Run. theVariable: {0}",theVariable)
    End Sub

    Public Sub Doubler(ByVal param As Integer)
       Console.WriteLine("In Method1. Received param: {0}",param)

       param *= 2

       Console.WriteLine("Updated param. Returning new value: {0}", _
       param)

    End Sub


 End Module
In Run. theVariable: 5
In Method1. Received param: 5
Updated param. Returning new value: 10
Back in Run. theVariable: 5








6.4.Pass by Reference
6.4.1.Pass value by reference
6.4.2.Demonstrates passing by reference.
6.4.3.Pass class by reference
6.4.4.Pass Decimal by reference