How to pass arguments in VB.NET part-1
In this article we discus how you pass the arguments like pass integer to a function in VB.NET.
When you call a function you need to be pass the arguments for the function which return some values which shows an output of the application. There are two ways to pass arguments to a function in Visual Basic:
- ByVal : This refers to a copy of the argument is passed to the function.
- ByRef : In ByRef procedure the actual argument itself is passed to the funtion.
In this article we discuss about the ByVal reference, We take a example and shows how to pass the value by ByVal reference.
EXAMPLE CODE
Module Module1
Sub value(ByVal A As Integer)
A = 100
Console.WriteLine("Value of A in sub: " & A)
End Sub
Sub Main()
Dim int As Integer = 50
Console.WriteLine("value before function call: " & int)
value(int)
Console.WriteLine("value after exit function : " & int)
Console.ReadLine()
End Sub
End Module
OUTPUT