Hello All,
I have created an user form which has a frame. The frame contains several labels. My objective is to highlight the label when mouse points to a label but highlight should disappear once mouse moves to next label and the next label should be highlighted.
Following is my code:
With above code, when mouse moves over a label it is highlighted. Next when mouse moves over a new label, new label is highlighted and old label is still highlighted. This continues. How can I remove the highlight from my previous label when mouse moves over new label.
Thanks
Angsuman
I have created an user form which has a frame. The frame contains several labels. My objective is to highlight the label when mouse points to a label but highlight should disappear once mouse moves to next label and the next label should be highlighted.
Following is my code:
Code:
Code is my user form:
Dim Labels() As New LblClass
Dim LabelCount As Long
Dim ctl As Control
' Create the Label objects
LabelCount = 0
For Each ctl In Frame1.Controls
If TypeName(ctl) = "Label" Then
LabelCount = LabelCount + 1
ReDim Preserve Labels(1 To LabelCount)
Set Labels(LabelCount).LabelGroup = ctl
End If
Next ctl
Created a class called LblClass and this class has following code:
Public WithEvents LabelGroup As MSForms.Label
Private Sub LabelGroup_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
LabelGroup.ForeColor = vbWhite
LabelGroup.SpecialEffect = 1
LabelGroup.BackStyle = 1
LabelGroup.BackColor = &H808000
End Sub
With above code, when mouse moves over a label it is highlighted. Next when mouse moves over a new label, new label is highlighted and old label is still highlighted. This continues. How can I remove the highlight from my previous label when mouse moves over new label.
Thanks
Angsuman