' Prevent modification of parameters (ByVal)
Imports System
Module Program
' This procedure receives x **ByVal**,
' meaning it gets a **copy** of the caller's value.
' Any modification inside this procedure does NOT affect the caller.
Sub PrintValue(ByVal x As Integer)
Console.WriteLine("Inside PrintValue, x = " & x)
' This modifies ONLY the local copy.
x = 20 ' allowed (local copy), caller is not affected
Console.WriteLine("Inside PrintValue after change, x = " & x)
End Sub
Sub Main()
Dim original As Integer = 10
Console.WriteLine("Before calling PrintValue, original = " & original)
' Pass original ByVal → PrintValue receives a copy
PrintValue(original)
' original remains unchanged
Console.WriteLine("After calling PrintValue, original = " & original)
End Sub
End Module
'
' run:
'
' Before calling PrintValue, original = 10
' Inside PrintValue, x = 10
' Inside PrintValue after change, x = 20
' After calling PrintValue, original = 10
'