Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse optional parameters with default values
Keywordsoptional, optional parameters, default
CategoriesTips and Tricks, Software Engineering
 
You cannot use IsMissing with this technique to see which arguments are missing. If you just want to use default values, however, this is easier and gives you stricter type checking than in available with Variants.

Use the Optional keyword before the parameter declaration and provide a default value after it. Optional parameters must come at the end of the parameter list. That means if one parameter is optional, all following parameters must also be optional.

 
Private Sub Draw(Optional X As Single = 720, Optional Y As _
    Single = 2880)
    Cls
    Circle (X, Y), 700
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated