【发布时间】:2020-10-10 06:41:37
【问题描述】:
我想要一个用于用户窗体控件事件的循环。
我有六个图像项;
button1
button1_hover
button2
button2_hover
button3
button3_hover
我使用名为 MouseMove 的事件来创建悬停语句。我是这样用这个方法的;
Private Sub button1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
button1.Visible = False
button1_hover.Visible = True
End Sub
Private Sub button2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
button2.Visible = False
button2_hover.Visible = True
End Sub
Private Sub button3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
button3.Visible = False
button3_hover.Visible = True
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
For i = 1 To 4
Me.Controls("button" & i).Visible = True
Me.Controls("button" & i & "_hover").Visible = False
Me.Controls("button" & i & "_click").Visible = False
Next
End Sub
它可以工作,但我想在一个循环中使用三个 mousemove 事件。
【问题讨论】:
标签: excel vba excel-2010 userform