Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable number of arguments in VB

Tags:

How to create a function with variable number of arguments in visual basic? ex.

x =  Sum(1,2,3) y =  Sum(1,2)  Function Sum('how to declare argument here') 'Is there any special argument manipulation inside function before it is usable? End Function 
like image 388
Kratz Avatar asked Apr 13 '10 14:04

Kratz


People also ask

What is a variable number of arguments?

To call a function with a variable number of arguments, simply specify any number of arguments in the function call. An example is the printf function from the C run-time library. The function call must include one argument for each type name declared in the parameter list or the list of argument types.

What is an argument in VB?

An argument represents the value that you pass to a procedure parameter when you call the procedure. The calling code supplies the arguments when it calls the procedure. When you call a Function or Sub procedure, you include an argument list in parentheses immediately following the procedure name.

What are argument variables?

Variable Arguments (Varargs) in Java is a method that takes a variable number of arguments. Variable Arguments in Java simplifies the creation of methods that need to take a variable number of arguments.


1 Answers

Have a look at Passing a Variable Number of Arguments

Function Sum(ParamArray Vals() As Variant)     Dim intLoopIndex As Integer     For intLoopIndex = 0 To  UBound(Vals)      Next intLoopIndex  End Function 
like image 195
Adriaan Stander Avatar answered Sep 28 '22 04:09

Adriaan Stander