VB.Net program to pass an array into user define the function
'VB.Net program to pass an array into user-defined function.
Module Module1
Function AddNum(ByVal arr() As Integer) As Integer
Dim result As Integer = 0
For i = 0 To arr.Length - 1 Step 1
result = result + arr(i)
Next
AddNum = result
End Function
Sub Main()
Dim result As Integer = 0
Dim arr() As Integer = New Integer(5) {1, 2, 3, 4, 5, 6}
result = AddNum(arr)
Console.WriteLine("Sum is: {0}", result)
End Sub
End Module
Sum is: 21
Press any key to continue . . .
Table of Contents