Part | Description | |
Public | Optional. Indicates that the Property Let procedure is accessible to all other procedures in all modules. If used in a module that contains an Option Private statement, the procedure is not available outside the project. | |
Private | Optional. Indicates that the Property Let procedure is accessible only to other procedures in the module where it is declared. | |
Static | Optional. Indicates that the Property Let procedure's local variables are preserved between calls. The Static attribute doesn't affect variables that are declared outside the Property Let procedure, even if they are used in the procedure. | |
name | Required. Name of the Property Let procedure; follows standard variable naming conventions, except that the name can be the same as a Property Get or Property Set procedure in the same module. | |
arglist | Required. List of variables representing arguments that are passed to the Property Let procedure when it is called. Multiple arguments are separated by commas. The name and data type of each argument in a Property Let procedure must be the same as the corresponding argument in a Property Get procedure. | |
value | Required. Variable to contain the value to be assigned to the property. When the procedure is called, this argument appears on the right side of the calling expression. The data type of value must be the same as the return type of the corresponding Property Get procedure. | |
statements | Optional. Any group of statements to be executed within the Property Let procedure. |
Part | Description | |
Optional | Optional. Indicates that an argument is not required. If used, all subsequent arguments in arglist must also be optional and declared using the Optional keyword. Note that it is not possible for the right side of a Property Let expression to be Optional. | |
ByVal | Optional. Indicates that the argument is passed by value. | |
ByRef | Optional. Indicates that the argument is passed by reference. ByRef is the default in Visual Basic. | |
ParamArray | Optional. Used only as the last argument in arglist to indicate that the final argument is an Optional array of Variant elements. The ParamArray keyword allows you to provide an arbitrary number of arguments. It may not be used with ByVal, ByRef, or Optional. | |
varname | Required. Name of the variable representing the argument; follows standard variable naming conventions. | |
type | Optional. Data type of the argument passed to the procedure; may be Byte, Boolean, Integer, Long, Currency, Single, Double, Decimal (not currently supported), Date, String (variable length only), Object, Variant. If the parameter is not Optional, a user-defined type, or an object type may also be specified. | |
defaultvalue | Optional. Any constant or constant expression. Valid for Optional parameters only. If the type is an Object, an explicit default value can only be Nothing. |
Dim CurrentColor As Integer
Const BLACK = 0, RED = 1, GREEN = 2, BLUE = 3
' Set the pen color property for a Drawing package.
' The module-level variable CurrentColor is set to
' a numeric value that identifies the color used for drawing.
Property Let PenColor(ColorName As String)
Select Case ColorName ' Check color name string.
Case "Red"
CurrentColor = RED ' Assign value for Red.
Case "Green"
CurrentColor = GREEN ' Assign value for Green.
Case "Blue"
CurrentColor = BLUE ' Assign value for Blue.
Case Else
CurrentColor = BLACK ' Assign default value.
End Select
End Property
' The following code sets the PenColor property for a drawing package
' by calling the Property let procedure.
PenColor = "Red"