VB中timer编写定时程序
发布网友
发布时间:2023-09-05 07:37
我来回答
共3个回答
热心网友
时间:2024-12-01 12:06
添加一个Timer1控件,2个按钮,代码:
Option Explicit
Private Ms As Long
Private n As Long
Private Sub Command1_Click()
Command2.Visible = False
n = Val(InputBox("请输入毫秒数!"))
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Ms = 0
Timer1.Interval = 1
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Ms = Ms + 1
If Ms = n Then
Command2.Visible = True
Timer1.Enabled = False
End If
End Sub
热心网友
时间:2024-12-01 12:06
Dim T As Long, A As Long
Private Sub Command1_Click()
T = Val(InputBox("输入时间t毫秒"))
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Command2.Visible = False
Timer1.Enabled = False
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
A = A + 1
If A >= T Then Command2.Visible = True: A = 0: Timer1.Enabled = False
End Sub
热心网友
时间:2024-12-01 12:07
你想要纯代码还是控件+代码?