Posted by: Sourav | September 13, 2016

ParamArray example in VB,VB Teacher Sourav,Kolkata 09748184075

Imports System

Module Module1

Sub Main()

addnumbers(2, 3, 4, 5, 6)
addnumbers(2, 3, New Object() {3, 4, 5})
addnumbers(1, 2, Nothing)
addnumbers(1, 2)


End Sub

Public Sub addnumbers(ByVal firstnumber As Integer, ByVal secondnumber As Integer, ByVal ParamArray rest As Object())
Dim result As Integer = firstnumber + secondnumber
If Not IsNothing(rest) Then
For Each i As Integer In rest
result = result + i

End If
Console.WriteLine(“The sum is {0}”, result)

End Sub
End Module


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: