Option Explicit
'local variable(s) to hold property value(s)
Private mvarstatus As Single 'local copy
Private mvardirection As Long 'local copy
Public Sub change_direction(ByVal new_direction As Integer)
If new_direction > 3 Or new_direction < 0 Then
Me.direction = InputBox("Error in light status.Enter a number 1 for forward 2 left turn 3 right turn ", "Error in Direction")
Else
Me.direction = new_direction
End If
End Sub
Public Sub Changer_status(ByVal new_status As Integer)
If new_status > 3 Or new_status < 0 Then
Me.status = InputBox("Error in light status.Enter a number 1 for forward 2 left turn 3 right turn ", "Error in Direction")
Else
Me.status = new_status
End If
End Sub
Public Property Let direction(ByVal vData As Long)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.direction = 5
mvardirection = vData
End Property
Public Property Get direction() As Long
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.direction
direction = mvardirection
End Property
Public Property Let status(ByVal vData As Single)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.status = 5
If vData > 3 Or vData < 0 Then
vData = InputBox("Error in light status.Enter a number 1 for green 2 for orange 3 for red", "Error in status")
Else
mvarstatus = vData
End If
End Property
Public Property Get status() As Single
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.status
If status > 3 Or staus < 0 Then
mvarstatus = InputBox("Error in light status.Enter a number 1 for forward 2 left turn 3 right turn ", "Error in Direction")
Else
status = mvarstatus
End If
End Property
Private Sub Class_Initialize()
Me.direction = 0
Me.status = 0
End Sub