patricktoulon1
New Member
- Joined
- Jan 23, 2025
- Messages
- 38
- Office Version
- 2013
- Platform
- Windows
hello i'me trying to scroll a listbox with a commandbutton but that dont work
can you help me please
VBA Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Const WM_VSCROLL = &H115
Const SB_LINEDOWN = 1
Const SB_LINEUP = 0
'event mouseUp for then button because i need a listbox focused
Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ListBox1.SetFocus
SendMessage ListBox1.[_GethWnd], WM_VSCROLL, SB_LINEUP, ByVal 0&
End Sub
Private Sub CommandButton2_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ListBox1.SetFocus
SendMessage ListBox1.[_GethWnd], WM_VSCROLL, SB_LINEDOWN, ByVal 0&
End Sub
Private Sub UserForm_Activate()
ListBox1.List = Evaluate("row(1:30)")
End Sub