Property Get Statement Example

This example uses the Property Get statement to define a property procedure that gets the value of a property. The property identifies the current color of a pen as a string.

Dim CurrentColor As Integer
Const BLACK = 0, RED = 1, GREEN = 2, BLUE = 3

' Returns the current color of the pen as a string.
Property Get PenColor() As String
    Select Case CurrentColor
        Case RED
            PenColor = "Red"
        Case GREEN
            PenColor = "Green"
        Case BLUE
            PenColor = "Blue"
    End Select
End Property

' The following code gets the color of the pen 
' calling the Property Get procedure.
ColorName = PenColor