点击按钮后,5秒时间后,ProgressBar走到一半,该怎么写呢?
找了很多答案,没找到确切的,请各位给我个代码哈,谢谢啦
[解决办法]
不知道这样行不:
Option ExplicitPrivate Sub Command1_Click() Timer1.Enabled = True ' ....... '其它代码End SubPrivate Sub Form_Load() Timer1.Enabled = False Timer1.Interval = 5000End SubPrivate Sub Timer1_Timer() Timer1.Enabled = False ProgressBar1.Value = (ProgressBar1.Max + ProgressBar1.Min) / 2 DoEventsEnd Sub
[解决办法]
'添加 Timer1 Command1 Progressbar1
Private Declare Function GetTickCount& Lib "kernel32" ()
Dim StartTm&, kk&, PerCent%
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = False
ProgressBar1.Min = 0
ProgressBar1.Max = 10
End Sub
Private Sub Command1_Click()
StartTm = GetTickCount
ProgressBar1.Value = 0
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
kk = Int((GetTickCount - StartTm) \ 1000)
ProgressBar1.Value = kk
PerCent = Int(kk / ProgressBar1.Max * 100)
Me.Cls: Print Str(PerCent) & "%"
If PerCent >= 100 Then
Timer1.Enabled = False
MsgBox "满啦"
End If
End Sub
[解决办法]
for ...next 里面加个 Doevents试看