In Visual Basic, I have functions with a lot of optional arguments. I would like to be able to pass only some of these optional arguments to a function without having to use numerous commas and spaces to get to the ones I want. Somewhere I saw a way for named parameters like OptVar:=val, but that doesn't seem to work. Just wondering if there is a way to do this. This will help readability.
Function foo(Optional val1 = 1, Optional val2 = 2, Optional val3 = 3)
End Function
Use foofor which only the last argument is needed:
fud = foo( , , 4)
a little cumbersome. It would be better if such a design worked:
fud = foo(val3:=4)
But that does not work.
source
share