有关VB 进度控制条(progressbar)控件问题
代码如下:PrivateSubCommand1_Click()Timer1.Enabled=FalseTimer2_TimerEndSubPrivateSubForm_L...
代码如下:
Private Sub Command1_Click()
Timer1.Enabled = False
Timer2_Timer
End Sub
Private Sub Form_Load()
ProgressBar1.Value = 0
ProgressBar1.Visible = True
Timer1_Timer
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = True
ProgressBar1.Value = ProgressBar1.Value + 1
If ProgressBar1.Value >= 100 Then
Unload Me
Timer1.Enabled = False
Unload Form2
Form3.Show
End If
End Sub
Private Sub Timer2_Timer()
Timer2.Enabled = True
ProgressBar1.Value = ProgressBar1.Value - 2
If ProgressBar1.Value <= 5 Then
ProgressBar1.Value = 0
Unload Me
Timer2.Enabled = False
End If
End Sub
单击command1控件调用timer2_timer事件后,大约4秒后 form3窗体仍能显示,请问怎么解决,还望高手赐教,谢谢! 展开
Private Sub Command1_Click()
Timer1.Enabled = False
Timer2_Timer
End Sub
Private Sub Form_Load()
ProgressBar1.Value = 0
ProgressBar1.Visible = True
Timer1_Timer
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = True
ProgressBar1.Value = ProgressBar1.Value + 1
If ProgressBar1.Value >= 100 Then
Unload Me
Timer1.Enabled = False
Unload Form2
Form3.Show
End If
End Sub
Private Sub Timer2_Timer()
Timer2.Enabled = True
ProgressBar1.Value = ProgressBar1.Value - 2
If ProgressBar1.Value <= 5 Then
ProgressBar1.Value = 0
Unload Me
Timer2.Enabled = False
End If
End Sub
单击command1控件调用timer2_timer事件后,大约4秒后 form3窗体仍能显示,请问怎么解决,还望高手赐教,谢谢! 展开
2个回答
展开全部
代码错了,你代码的顺序不对,你的代码有好几处错,都是顺序的错误
追问
请明示,谢谢!
追答
timer1这样改:
Private Sub Timer1_Timer()
Timer1.Enabled = True
ProgressBar1.Value = ProgressBar1.Value + 1
If ProgressBar1.Value >= 100 Then
Unload Form2
Form3.Show
Timer1.Enabled = False
Unload Me
End If
End Sub
改下代码执行的顺序就行了 ,UNLOAD这代表的是卸载窗体的过程,如果先执行这个,当前的窗体被卸掉了,timer1在这时停止,后面的form3来不及执行了,这就是为什么不出form3的原因。
timer2也一样:
Private Sub Timer2_Timer()
Timer2.Enabled = True
ProgressBar1.Value = ProgressBar1.Value - 2
If ProgressBar1.Value <= 5 Then
ProgressBar1.Value = 0
Timer2.Enabled = False
Unload Me
End If
End Su
同理,如果这里不改一下的话,调试是不会出错的,但是如果生成exe的话,就会报错
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询