Export (0) Print
Expand All

Procedure Calling Sequence for Visual Basic 6.0 Users 

Visual Basic 2005 introduces several changes affecting procedure calling sequences. These changes improve syntax consistency.

Parentheses in Procedure Calls

Visual Basic 6.0

In Visual Basic 6.0, parentheses are required around the argument list in Function calls. In Sub calls, they are required if you use the Call statement and forbidden if you do not. The following example shows valid calling statements:

y = Sqrt(x)

Call displayCell(2, 14, cellValue)

displayCell 2, 14, cellValue ' Variation on previous statement.

Visual Basic 2005

In Visual Basic 2005, parentheses are always required around a non-empty argument list in any procedure call. In Sub calls, the Call statement is optional. The preceding example can be rewritten as follows:

    Y = Math.Sqrt(X)
...    DisplayCell(2, 14, Value)

If you are calling a procedure without supplying any arguments, you can include empty parentheses or leave them out altogether.

Return Statement

Visual Basic 6.0

In Visual Basic 6.0, you use the Return statement only to branch back to the code following a GoSub statement. Both statements must be in the same procedure.

Visual Basic 2005

In Visual Basic 2005, the GoSub statement is not supported, and you can use the Return statement to return control to the calling program from a Function or Sub procedure.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft