Parameters And Keywords

gray

Registered User.
Local time
Today, 19:48
Joined
Mar 19, 2007
Messages
578
Hi

Seems like a basic question but I can't find an obvious answer...

When calling a procedure in VB I often get snow-blinded by the keywords and parameters (AKA 'arguments'). On the world's greatest operating system (ICL VME/B) we used SCL. One of SCL's features was to be able to call a proc with:

Call My_Test_Proc(False,False,"Fred",False,True,"Jim","False")

In this case, you have to try to remember the order, type and whether mandatory or optional.

But it would also let you specify:

Call My_Test_Proc(LockRec=False,AddNewRec=False,ContactName="Fred",ExtgContact=False,CreateDirEntry=True,FName="Jim",Employee="False")

Soooooo much easier to read and to amend...

Actually it would also let you specify:
Call My_Test_Proc(LockRec=False,ContactName="Fred",False,CreateDirEntry=True,FName="Jim")

So missing out optional parameters which would take their default... and it didn't care about the order... there were a dozen other features with SCL parameters ... far too many to go into here...

My question is then, is there the equivalent in VB?... so Call My_Proc(Keyword1=Parameter1 Value,Keyword2=Paramter2 Value)?

I've tried this and just get compile errors....

Thanks
 
MS Office VBA supports a similar syntax but most developers use the concise format because we don't like typing.

Function(ArgumentName:=Value, etc)
 
Ah you see that's what touch typing was invented for! :)

I'll give that syntax a whirl ! Thanks!
 
That syntax did not work so I'm guessing MS Office VBA is not the same thing as MS Access VBA? Will the real VB please stand up! :)
 
it does work. and furthermore named parameters can be in any order. i suspect you are getting a syntax error of some sort. you need a colon to specify a named parameter

you should also get intellisense to help enable you to complete all the arguments
 
Don't forget to put string argument values in quotes.

But as Dave said, Intellisense is the way to go.
 
Ah I see my problem... I was running this in a RunCode Action of a Macro which doesn't seem to comprehend the syntax...

As you say, I have called it from VB and it does indeed work... Thanks for the advice gents.
 

Users who are viewing this thread

Back
Top Bottom