Рет қаралды 5,089
💡 Source Code:
Private Sub UserForm_Activate()
With Me
.Height = Application.Height
.Width = Application.Width
.Left = Application.Left
.Top = Application.Top
End With
End Sub
' act_tb, prev_tb and next_tb are the names of the text boxes
Sub MouseMoveForBtns(ByVal btn_i As Byte)
Dim min_index As Byte, max_index As Byte, i As Byte
min_index = 1
max_index = 10
For i = min_index To max_index
With Me.Controls("CommandButton" & i)
If i = btn_i Then
.BackColor = vbYellow
.ForeColor = vbBlack
act_tb = Controls("CommandButton" & i).Caption
If i - 1 ◀ min_index Then
prev_tb = ""
prev_tb.BackStyle = fmBackStyleOpaque
next_tb = Controls("CommandButton" & i + 1).Caption
ElseIf i + 1 ▶ max_index Then
prev_tb = Controls("CommandButton" & i - 1).Caption
next_tb = ""
next_tb.BackStyle = fmBackStyleOpaque
Else:
prev_tb.BackStyle = fmBackStyleTransparent
next_tb.BackStyle = fmBackStyleTransparent
prev_tb = Controls("CommandButton" & i - 1).Caption
next_tb = Controls("CommandButton" & i + 1).Caption
End If
Else:
.BackColor = &H800080
.ForeColor = vbWhite
End If
End With
Next i
End Sub
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(1)
End Sub
Private Sub CommandButton2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(2)
End Sub
Private Sub CommandButton3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(3)
End Sub
Private Sub CommandButton4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(4)
End Sub
Private Sub CommandButton5_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(5)
End Sub
Private Sub CommandButton6_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(6)
End Sub
Private Sub CommandButton7_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(7)
End Sub
Private Sub CommandButton8_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(8)
End Sub
Private Sub CommandButton9_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(9)
End Sub
Private Sub CommandButton10_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Call MouseMoveForBtns(10)
End Sub
------------------------------------------------------------------------------------------
Buy a Cofee ☕ for theworldofalgorithms: ko-fi.com/theworldofalgorithms
🥰Thank you for the donation. I am deeply grateful for your help!🥰
------------------------------------------------------------------------------------------
#excelvbatutorial
#msexcel
#msexceltutorial
#msexcelcourse
#vba
#vbatutorial
#excelvba
#excelvbatutorial
#microsoftexceltutorial
#tutorial
#exceltutorial
#excelvbatutorial
#vbatutorial
#mousemoveevent
#mousemove
#vbamousemoveevent
#commandbutton
#label
#textbox
#vbacommandbutton
#vbalabel
#vbatextbox
#algorithm
#changebuttoncolor
#menu
#menubar
#vbamenubar
#excelvbamenubar
#runamacro
#macro
#vbamacro
#excelvbamacro
#advancedexcel