Monday, 16 December 2019

A Bit VB - ByVal and ByRef

VB.NET program that shows ByVal and ByRef Module ModuleExample Sub Main() Dim value As Integer = 10 ' The integer value doesn't change here when passed ByVal. ExampleMethod1(value) Console.WriteLine(value) ' The integer value DOES change when passed ByRef. ExampleMethod2(value) Console.WriteLine(value)
End Sub Sub ExampleMethod1(ByVal achieve As Integer) achieve = 100 End Sub Sub ExampleMethod2(ByRef achieve As Integer) achieve = 100
End Sub
End Module Output 10 100

No comments:

Post a Comment