Procedure Declaration for Visual Basic 6.0 Users

Visual Basic 2008 introduces several changes related to the declaration of procedures.

Optional Arguments

Visual Basic 6.0

In Visual Basic 6.0, you can declare a procedure parameter as Optional without specifying a default value. If an optional parameter is of the Variant type, the procedure code can use the IsMissing function to determine whether the calling code passed an argument to that parameter.

Visual Basic 2008

In Visual Basic 2008, every optional parameter must declare a default value, which is passed to the procedure if the calling program does not supply that argument. The IsMissing function is not needed to detect a missing argument, and it is not supported. The following example shows an optional argument declaration:

Sub Calculate(OptionalByVal Switch AsBoolean = False)

Static Local Variables

Visual Basic 6.0

In Visual Basic 6.0, you can declare a procedure with the Static modifier. This causes every local variable within the procedure to be static and to retain its value between calls.

Visual Basic 2008

In Visual Basic 2008, the Static keyword is not supported in a Function or Sub statement. You must individually declare each local variable you want to be Static.

See Also

Concepts

Procedure Calling Sequence for Visual Basic 6.0 Users

Parameter Passing Mechanism for Visual Basic 6.0 Users

Programming Element Support Changes Summary

Reference

Optional (Visual Basic)

Static (Visual Basic)