我想用一个进程条来表示一个虚假的进程,只是想在一个长时间动作开始后,有一个显示给客户看,当动作完成后,进程条退出,表示动作完成。
我用Timer来控制进程条,发现加入一个长时间的动作代码后,并不能得到效果,总是在动作代码运行完后,直接就报出了结束的消息,不能得到想要的进度
的显示请教,,应该如何实现这个功能。。谢谢
本人代码如下
Dim i As Integer
Dim stopT As BooleanPrivate Sub Form_Load()
stopT = False
i = 0
bar.Max = 50
bar.Min = 0
Timer1.Enabled = True
Call doit
End SubPrivate Sub Timer1_Timer()
bar.Value = i
i = i + 1 If i = 50 Then
i = 0
End If
If stopT = True Then
Call stopBar
End If
End SubPrivate Sub stopBar()
Timer1.Enabled = False
MsgBox "over"
End Sub
Private Sub doit()
Dim count As Long
For count = 0 To 10000000
count = count + 1
Next count
stopT = True
End Sub
我用Timer来控制进程条,发现加入一个长时间的动作代码后,并不能得到效果,总是在动作代码运行完后,直接就报出了结束的消息,不能得到想要的进度
的显示请教,,应该如何实现这个功能。。谢谢
本人代码如下
Dim i As Integer
Dim stopT As BooleanPrivate Sub Form_Load()
stopT = False
i = 0
bar.Max = 50
bar.Min = 0
Timer1.Enabled = True
Call doit
End SubPrivate Sub Timer1_Timer()
bar.Value = i
i = i + 1 If i = 50 Then
i = 0
End If
If stopT = True Then
Call stopBar
End If
End SubPrivate Sub stopBar()
Timer1.Enabled = False
MsgBox "over"
End Sub
Private Sub doit()
Dim count As Long
For count = 0 To 10000000
count = count + 1
Next count
stopT = True
End Sub
count = count + 1
doevents
Next count
stopT = False
bar.Max = 50
bar.Min = 0
Timer1.Enabled = True
Call doit
End SubPrivate Sub Timer1_Timer() If bar.Value = bar.Max Then
bar.Value = 0
Else
bar.Value = bar.Value + 1
End If
bar.Refresh '强制刷新
If stopT = True Then
bar.Value = bar.Max
Call stopBar
End If
End SubPrivate Sub stopBar()
Timer1.Enabled = False
MsgBox "over"
End SubPrivate Sub doit()
Dim count As Long
For count = 0 To 10000000
count = count + 1
Next count
stopT = True
End Sub注意,编译成 .exe 文件后执行,才能使 Timer 并发。
ProgressBar1.Value = ProgressBar1.Value + 10
If ProgressBar1 >= 1000 Then
ProgressBar1.Enabled =Flase
Timer1.Enabled = False
End If
End Sub
doit
End SubPrivate Sub Form_Initialize()Picture1.Move 0, 0, Me.Width, Me.Height / 5
Set Picture2.Container = Picture1
Picture2.AutoRedraw = True
'picture2.picture=loadpicture("c:\123.jpg") '用图片效果更好
Picture1.ScaleWidth = 1000000
Picture2.Move 0, 0, 0, Picture1.Height
Picture2.BackColor = vbRed '
End SubPrivate Sub doit()
Dim i As Long, max As Integer
For i = 0 To 1000000
DoEvents
Picture2.Width = i
Next
MsgBox "over"
End Sub