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
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With