Syntax 1 |
...(expression)... |
Syntax 2 |
...,(parameter),... |
Description |
Forces parts of an expression to be evaluated before others or forces a parameter to be passed by value. |
Comments |
Parentheses within Expressions Parentheses override the normal precedence order of the scripts operators, forcing a subexpression to be evaluated before other parts of the expression. For example, the use of parentheses in the following expressions causes different results: i = 1 + 2 *
3 'Assigns 7. Use of parentheses can make your code easier to read, removing any ambiguity in complicated expressions. |
|
Parentheses Used in Parameter Passing Parentheses can also be used when passing parameters to functions or subroutines to force a given parameter to be passed by value, as shown below: ShowForm
i 'Pass i by reference. Enclosing parameters within parentheses can be misleading. For example, the following statement appears to be calling a function called ShowForm without assigning the result: ShowForm(i) The above statement actually calls a subroutine called ShowForm, passing it the variable i by value. It may be clearer to use the ByVal keyword in this case, which accomplishes the same thing: ShowForm ByVal i The result of an expression is always passed by value. |
Example |
This example uses parentheses to clarify an expression. Sub Main() If (dave And bill) Or (jim And
bill) Then |
See Also |
ByVal (keyword); Operator Precedence (topic). |
Symbols |