vb倒计时运行某个窗体代码

2025-04-16 13:14:17
推荐回答(3个)
回答1:

timer1的属性为 enabled=FALSE interval=1000假设是按command1设置时间 text1为设置的时间 则代码如下:dim t as integerprivate sub form1_load() text1=""end subprivate sub command1_click() t=text1 timer1.enabled=tureend subprivate sub timer1_timer() t=t-1 if t=0 then load form2:form2.show:timer1.enabled=falseend sub

回答2:

Dim times As IntegerPrivate Sub Command1_Click()
If IsNumeric(Text1.Text) Then
Timer1.Enabled = True
Else
MsgBox "请输入正确的数字(秒)"
Exit Sub
End If
End SubPrivate Sub Form_Load()
Text1.Text = ""
Timer1.Enabled = False
End SubPrivate Sub Timer1_Timer()
Text1.Text = Text1.Text - 1
If Text1.Text = 0 Then
Load Form2
Form2.Show
Timer1.Enabled = False
End If
End Sub

回答3:

Private Sub Command1_Click()
Timer1 = True
End SubPrivate Sub Form_Load()
Timer1 = False
Timer1.Interval = 1000
Text1 = 5
End SubPrivate Sub Timer1_Timer()
Text1 = Text1 - 1
If Text1 = 0 Then
Form2.Show
End If
End Sub