روی فرم حود یک کنترل فرمان مثلا بنام cmdrun قرار دهید
هر تعداد کنترل فرمان دیگر که باید دستورات شما را اجرا کنند (در این مثال 5 تا) با یک نام روی فرم ایجاد کنید مثلا (command1(1) ،command1(0 و.... دقت کنید tabindex آنها از یک تا پنج باشد
یک کنترل تایمر به فرم اضافه کرده و interval آن را صفر . enabled آن را false قرار دهید
دستورات زیر را اضافه کنید
برنامه را با کلیک دکمه cmdrun اجرا کنید
Dim duration(4) As Integer, cc As Integer
()Private Sub cmdrun_Click
Timer1.Enabled = True
Timer1.Interval = duration(0)
End Sub
(Private Sub Command1_Click(Index As Integer
Select Case Index
Case 0
Print "command1 is running"
Case 1
Print "command2 is running"
Case 2
Print "command3 is running"
Case 3
Print "command4 is running"
Case 4
Print "command5 is running"
End Select
End Sub
Private Sub Form_Load()
duration(0) = 2000
duration(1) = 3000
duration(2) = 5000
duration(3) = 4000
duration(4) = 2000
End Sub
Private Sub Timer1_Timer()
Command1(cc).Value = True
SendKeys "{tab}"
cc = cc + 1
If cc = 5 Then
Timer1.Enabled = False
Exit Sub
End If
Timer1.Interval = duration(cc)
End Sub