Hi,
To try this VB code put the following controls on a form:
(This is a sample for 1 command button).
Command1
Label1
Timer1
* * * *
The code for 4 command buttons:
Your program has 4 buttons so you will need a global
variable to tell Timer1_Timer() which button is MouseDown.
Set the value of your global variable in the 4 subroutines commandX_MouseDown()
and in Timer1_Timer() with a "Select Case" or with more "IF"
you can do your conditional execution based on the global variable value.
Best regards,
Luciano
Code:
'=============================
Private Sub Form_Load()
Label1.Caption = 1
Command1.Caption = "Test"
Timer1.Enabled = False
End Sub
'=============================
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Interval = 100 '~ 100 ms. try 10 or 1000
Timer1.Enabled = True
End Sub
'=============================
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = False
End Sub
'============================
Private Sub Timer1_Timer()
Label1.Caption = Label1.Caption + 1
End Sub
'=============================
Bookmarks