Function with dynamic number of arguments?

skyyakal

Well-known member
Joined
Oct 3, 2003
Messages
74
Is there a possibility to call a function without giving the number of arguments?

for example
DIM func(LaLaLaLa) As Integer

and then call for example one time func(4, 7, 3, 8) and the second time
func(1, 3)?

Would appreciate the answer.
 
Yes, if you overload the fuction, meaning that you need to create the lets say three functions with the same name but different signature on each, eg.

Code:
Private myFunc() as string
    TODO
End Function

Private myFunc(x as integer) as string
    TODO
End Function

Private myFunc(x as integer, y as integer) as string
    TODO
End Function

Private myFunc(x as integer, y as integer, s as string) as string
    TODO
End Function
 
You can also set the function to its maximum arguments and only utilize those necessary depending on its requirements at the time. In fact, one of the arguments could be the determinator to which calculations are used and by which variables.
 
Back
Top