Link to home
Start Free TrialLog in
Avatar of gjok
gjokFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Passing null or Optional values to functions in VB6

I have written a DLL function that takes 11 parameters, However all eleven parameters may not allways be needed.
How can I call my function in a way that I dont have to specify emtpy strings. ie like this:

     X = myFunction(Val1, Val2, Val3, , , , , , , Val10, Val11)

Currently I have to do this :

     X = myFunction(Val1, Val2, Val3, "", "", 0, 0, "", 0, Val10, Val11)

MSDN says:
An argument can only be omitted from a call to a user-defined procedure if it was declared Optional in the procedure declaration. Either supply the argument in the call or declare the parameter Optional in the definition.

I have tried:
Optional Val1 As String
Val1 As Optional String
Val1 As String Optional, etc

Please advise,
John
ASKER CERTIFIED SOLUTION
Avatar of Dabas
Dabas
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gjok

ASKER

Many thanks, that works great!