1

Can anybody give me an example to change my mind?

I've seen this elswhere on SO:

The purpose of the Call statement when used with a Sub is to allow you to enclose the argument list in parentheses.

That to me is not a valid purpose. It just makes code slightly less readable.

Community
  • 1
  • 1
Nick
  • 3,573
  • 12
  • 38
  • 43
  • 2
    http://stackoverflow.com/questions/2573597/should-i-use-call-keyword-in-vb-vba –  Aug 08 '13 at 16:40
  • There can be side effects of calling a sub with parentheses but without call, so possibly its an attempt to clarify intent? (still a weak reason) – Alex K. Aug 08 '13 at 17:05
  • I hate that calls can be made without the CALL key word and parentheses. I always include them. – tbur Aug 08 '13 at 18:20

1 Answers1

0

I use the call statement when I am making a method call into some object like a form, where the length of the statement makes it not immediately clear that it is a method call.

Call Forms!frmInvoice.Form!UpdateLineItems(taxRate)

The argument could be made that making all method calls use parentheses improves readability by making all such calls consistent. Of course, making them all functions instead of subs avoids the problem altogether.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501