Module Module1
Sub Main()
Dim n As Integer = 5
s(n)
Console.WriteLine(n)
s_byval(n)
Console.WriteLine(n)
s_byref(n)
Console.WriteLine(n)
End Sub
Sub s(n As Integer) ' ByVal is the default
n = 111
End Sub
Sub s_byval(ByVal n As Integer)
n = 222
End Sub
Sub s_byref(ByRef n As Integer)
n = 333
End Sub
End Module
'run:
'
' 5
' 5
' 333