Make A Toggle Button

Toggle button is button that when clicked it's stays down until it's clicked again.


Add 1 Command Button to your form.

Module Code

Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long

Public Const BM_SETSTATE = &HF3

Form Code

Private mb_ButtonDown As Boolean
Private Sub Command1_Click()
    mb_ButtonDown = Not mb_ButtonDown
    Call SendMessage(Command1.hwnd, BM_SETSTATE, CInt(mb_ButtonDown), 0&)
End Sub

Go Back