1

I have a method which contains a ParamArray parameter and was wondering if there was some special notation i could use in VBA to get the same effect as:

method val1, _
         val2, _
         new object(){prop1:=val11, _
                      prop2:=val12}, _
         new object(){prop1:=val21, _
                      prop2:=val22}

Its not pretty but should get the point acrossed. Basically i am trying to translate the skills/logic i have learned to use in .Net, since 1.0, and try to incorporate a similar logic design in VBA.

1 Answer 1

1

Assuming you mean the object construction shorthand then no, there is no direct equivalent.

If the member names are the same then you could use a factory function

method val1, val2, makeFoo(val11, val12), makeFoo(val21, val22)
.
.
.
function makeFoo(prop1 as string, prop2 as string) As clsFoo
   set makeFoo = new clsFoo
   makeFoo.prop1 = prop1
   makeFoo.prop2 = prop2
end function

Optional params would allow named arguments too makeFoo(prop1:=val11, ...

Sign up to request clarification or add additional context in comments.

1 Comment

tyvm...i was hoping not to make a helper function but seems VBA hasnt developed over the last 20yrs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.