Jumat, 14 Desember 2012

RE: [ExcelVBA] Using Parentheses in Subroutine Calls

 

VB, and hence VBA, treats anything in parentheses as expressions to be
evaluated (even if that thing is not really an expression, such as a
variable name). If the call requires two or more arguments, enclosing them
in parentheses will force an error as a comma separated list is not a proper
expression that VB/VBA can evaluate.

From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On Behalf
Of mickey11030
Sent: 14 December 2012 02:18
To: ExcelVBA@yahoogroups.com
Subject: [ExcelVBA] Using Parentheses in Subroutine Calls

The rule is that if you call a subroutine using the Call keyword, you
must enclose the argument list in parentheses. That is
Call Test(a, b)
is correct. But if you omit Call, you must not use parentheses, so that
Test a, b
is also correct. I didn't know these rules, and, from habit, I do not
use Call and do use parentheses. I got away with that for a long time
because my subroutines used only 1 argument. Surprisingly,
Test (c)
works even though it violates the rule. I got into trouble only when I
wrote a subroutine that used 2 arguments.
Test (c, d)
causes a syntax error. Does anyone know why the single argument works
with a parentheses?

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar