Calling a Sub syntax question

  • Thread starter Thread starter MyndPhlyp
  • Start date Start date
M

MyndPhlyp

I've run into something odd when it comes to calling a Sub in my code.

Most everywhere, whenever I call a Sub, the syntax is:

SubName(param, param, etc.)

But on this one Sub, the VB editor wants the syntax:

SubName param, param, etc.

If I attempt to use the normal syntax, it complains that there isn't an "="
after the call indicating it thinks an assignment is necessary.

The only difference (aside from the internal logic) between this Sub and
other Subs is that I call this one recursively. I've stared at the code for
hours looking for a misplaced or missing punctuation mark or operator to no
avail. I've tried commenting out chunks of code trying to make the editor
happy with the same lack of success.

The code runs using the queer syntax, but it bothers me.

What's going on? Is this normal?
 
Allen Browne said:
Try the Call keyword, and place the arguments in parentheses.

That works, but why doesn't the normal way (without the Call and using
parenthesized parameters)?
 
In theory, it should work either way.

In practice, there is only one possible way for Access to interpret the line
when the Call keyword is used. Without it, the interpretation depends on
what Access does with all the words: can it match them against anything in
one of the libraries you are using? against a name anywhere in scope? etc.

VBA is an incredibly loose language. Anything you can do to help it pin down
the meaning precisely is worth the effort.
 
Allen Browne said:
In theory, it should work either way.

In practice, there is only one possible way for Access to interpret the line
when the Call keyword is used. Without it, the interpretation depends on
what Access does with all the words: can it match them against anything in
one of the libraries you are using? against a name anywhere in scope? etc.

VBA is an incredibly loose language. Anything you can do to help it pin down
the meaning precisely is worth the effort.

I thought about the Sub's name colliding with some other Sub, Function or
Property (or DLL entry point, macro, blah, blah, etc.) not necessarily in
the code I'm playing with. Changing the Sub's name to something radically
different (akin to alphabet soup) didn't alleviate the problem even though
there was little chance of it matching up and overloading any other
definition.

Must be just a "feature" of the tool. I guess I'll just have to accept it as
one of those mysteries of life. (Damn ... I really hate having to Call when
I shouldn't have to. It just messes up the readability of the code.)

Thanx.
 
Back
Top