在
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Label1.Caption = Label1.Caption + 2
Sleep 1000
Label1.Caption = Label1.Caption + 2
End Sub
中
VB会先停止1秒后
Label1.Caption = Label1.Caption + 2
Label1.Caption = Label1.Caption + 2
两个一起运行,而不是运行前一个后停止后再运行
Label1.Caption = Label1.Caption + 2
,应该怎么弄才可以
timer怎么弄,详细下
VB等待后执行
答案:2 悬赏:80 手机版
解决时间 2021-02-10 18:00
- 提问者网友:沉默的哀伤
- 2021-02-09 18:59
最佳答案
- 五星知识达人网友:枭雄戏美人
- 2021-02-09 20:36
在窗体上画一timer控件,用下面的代码。
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Label1.Caption + 2
End Sub
也可以这样:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Label1.Caption = Label1.Caption + 2
DoEvents
Sleep 1000
Label1.Caption = Label1.Caption + 2
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Label1.Caption + 2
End Sub
也可以这样:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Label1.Caption = Label1.Caption + 2
DoEvents
Sleep 1000
Label1.Caption = Label1.Caption + 2
End Sub
全部回答
- 1楼网友:神的生死簿
- 2021-02-09 21:23
public sub timedelay(byval pausesecond as single) ' attribute timedelay.vb_description = "延时" dim star, pausetime star = timer pausetime = pausesecond do while timer < star + pausetime doevents loop end sub
private sub command1_click() timedelay (5) msgbox "出来了" end sub 暂停5秒执行下一条语句
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯