Article ID: 177627
Article Last Modified on 7/13/2004
Option Explicit
Private CurrentValue As OLE_OPTEXCLUSIVE
Private Sub UserControl_InitProperties()
'Set the initial value for the Value property to False...much
'like an option button would set its initial value to False
'(unselected).
Me.Value = False
End Sub
Private Sub UserControl_Click()
'When the User Clicks on the control, the Value property of the
'control will be set to True, just as an option button
'sets its value to True when it is clicked.
Me.Value = True
End Sub
Public Property Get Value() As OLE_OPTEXCLUSIVE
'Retrieve the current value of the Value property
Value = CurrentValue
End Property
Public Property Let Value(ByVal NewValue As OLE_OPTEXCLUSIVE)
'If the NewValue is True, the UserControls color is set
'to green and all other instances of the control within
'a container are set to False automatically.
'
'If NewValue is False, the UserControls color is set to red.
If NewValue = True Then
UserControl.BackColor = &HFF00& 'Green
CurrentValue = NewValue
PropertyChanged "Value" 'Notifies the container that the
'property has changed. If you exclude
'this line of code, the ActiveX
'control will not behave as an
'option group because there is no
'mechanism to inform the container
'that the property has changed.
Else
UserControl.BackColor = &HFF& 'Red
CurrentValue = NewValue
PropertyChanged "Value"
End If
End Property
Keywords: kbhowto KB177627