Procedure Calling Sequence Changes in Visual Basic



Procedure Calling Sequence Changes in Visual Basic

 
Visual Basic .NET 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, Value)
DisplayCell 2, 14, Value  ' Variation on previous statement.

Visual Basic .NET

In Visual Basic .NET, 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 = 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 .NET

In Visual Basic .NET, 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.