VB中timer编写定时程序
先单击command1,command2.visible=false弹出inputbox输入时间t毫秒,要求过了t毫秒后command2.visible=true该如何编...
先单击command1,command2.visible=false弹出inputbox输入时间t毫秒,要求过了t毫秒后command2.visible=true
该如何编写程序代码?谢谢 展开
该如何编写程序代码?谢谢 展开
3个回答
展开全部
添加一个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
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
展开全部
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
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
更多追问追答
追问
追答
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
修改这个地方就可以了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你想要纯代码还是控件+代码?
更多追问追答
追问
只要代码就行…
追答
其实这个只能通过代码实现,不能用timer,等会给你发上来
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询