用VB编写倒计时器的时候我设置倒计时为20秒,怎么开始倒计时的时候是1199开始倒计啊?

发布于2022-01-13 10:48:29

用VB编写倒计时器的时候我设置倒计时为20秒,怎么开始倒计时的时候是1199开始倒计啊? 下面是代码Dim m As LongPrivate Sub Command1_Click()Timer1.Enabled = Truem = Val(Text1.Text) * 60Label1.Caption = "现在开始倒计时"Command1.Visible = FalseEnd SubPrivate Sub Timer1_Timer()m = m - 1If m < 0 ThenTimer1.Enabled = FalseMsgBox "时间到", 0, "倒计时"Label1.Caption = " 请输入倒计时的分钟数"Text1.Text = ""Command1.Visible = TrueElseText1.Text = mEnd IfEnd Sub

2个回答
admin
网友回答2022-01-13
timer 是以毫秒为单位的 不知道你的20秒是怎么输入的 m = Val(Text1.Text) * 60
admin
网友回答2022-01-13

这样:

dim t as integer

private sub command1_click()     timer1.enabled = true end sub

private sub form_load()     t = 5     timer1.enabled = false     timer1.interval = 1000 end sub

private sub timer1_timer()     label1.caption = int(rnd * (100000))     t = t - 1     if t = 0 then     timer1.enabled = false     end if end sub

回到
顶部