Parenthesis are required when they are required, and optional when they are optional. In the case of empty parameter/argument lists parenthesis are "just for show".
A Sub Procedure can be declared as Sub Main()
or Sub Main
- the parenthesis are optional when there are no parameters. Likewise, procedures/functions can be invoked without parenthesis if (and only if) no arguments are supplied.
Sub A ' ok, no parameter list - no need for parenthesis
Sub A() ' it's fine to use parenthesis anyway
Sub B(x as Integer) ' need parenthesis for parameter list
obj.A ' ok, no arguments - no need for parenthesis
obj.A() ' it's fine to use parenthesis anyway
obj.B(42) ' need parenthesis when arguments are specified
In the above, the definitions of A
and invocations of A
are equivalent as the parenthesis are optional in these cases.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…