Mega Code Archive

 
Categories / VB.Net Tutorial / Class Module
 

Pass value by reference

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