This documentation is archived and is not being maintained.

Procedure Declaration for Visual Basic 6.0 Users 

Visual Basic 2005 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 2005

In Visual Basic 2005, 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(Optional ByVal Switch As Boolean = 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 2005

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

Show: