VB and VBA Users Source Code: Using Optional Parameters with Property Let and Get
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Using Optional Parameters with Property Let and Get
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Thursday, October 26, 2000
Hits:
1121
Category:
Visual Basic General
Article:
When declaring a sub or function, if you specify an optional parameter then all the following parameters must also be optionals. However, property Let and Get only work if the optional parameters are at the start of the parameter list. Note, that the value parameter is the last value in the list of arguments. Below is a fictional example of a situation where it may be useful to use optional parameters in a property construct. Please note, this code must be placed in a Class Module: 'Note the optional parameters are placed before the value parameter, 'and the optional parameter names must be identical Public Property Let DatabaseName(Optional bPathIncluded As Boolean, sDatabase As String) 'Place code here End Property Public Property Get DatabaseName(Optional bPathIncluded As Boolean) As String 'Place code here End Property
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder