VB实时错误 380 无效属性值,怎么改?(第一次运行没问题,但再运行一次就报错)
第一个窗体代码:PrivateSubCommand1_Click()form2.showendsub第二个窗体:PrivateSubCommand1_Click()Tim...
第一个窗体代码:
Private Sub Command1_Click()
form2.show
end sub
第二个窗体:
Private Sub Command1_Click()
Timer1.Enabled = False
Timer2.Enabled = True
Timer2_Timer
End Sub
Private Sub Form_Load()
ProgressBar1.Visible = True
Timer1.Enabled = True
Timer1_Timer
End Sub
Private Sub Timer1_Timer()
ProgressBar1.Value = ProgressBar1.Value + 2
If ProgressBar1.Value >= 100 Then
Me.Hide
Timer1.Enabled = False
Unload Form2
Form3.Show
End If
End Sub
Private Sub Timer2_Timer()
ProgressBar1.Value = ProgressBar1.Value - 2
If ProgressBar1.Value <= 0 Then
Me.Hide
Timer2.Enabled = False
End If
End Sub
第二次运行时,进度条就不显示了,若这时启动 timer2_timer 事件则会报错 展开
Private Sub Command1_Click()
form2.show
end sub
第二个窗体:
Private Sub Command1_Click()
Timer1.Enabled = False
Timer2.Enabled = True
Timer2_Timer
End Sub
Private Sub Form_Load()
ProgressBar1.Visible = True
Timer1.Enabled = True
Timer1_Timer
End Sub
Private Sub Timer1_Timer()
ProgressBar1.Value = ProgressBar1.Value + 2
If ProgressBar1.Value >= 100 Then
Me.Hide
Timer1.Enabled = False
Unload Form2
Form3.Show
End If
End Sub
Private Sub Timer2_Timer()
ProgressBar1.Value = ProgressBar1.Value - 2
If ProgressBar1.Value <= 0 Then
Me.Hide
Timer2.Enabled = False
End If
End Sub
第二次运行时,进度条就不显示了,若这时启动 timer2_timer 事件则会报错 展开
2个回答
展开全部
ProgressBar1.Value = ProgressBar1.Value - 2 将造成 ProgressBar1.Value <0 的错误
要么你把 ProgressBar1.Value = ProgressBar1.Value - 2 放到If ProgressBar1.Value <= 0 Then
的后面
要么你就得将ProgressBar1.Value - 2 先放入一个变量然后判断这个变量值确实不小于0才能赋值给ProgressBar1.Value
要么你在每次前先给ProgressBar1.Value 赋初值,以确保ProgressBar1.Value - 2不会产生负数
要么你把 ProgressBar1.Value = ProgressBar1.Value - 2 放到If ProgressBar1.Value <= 0 Then
的后面
要么你就得将ProgressBar1.Value - 2 先放入一个变量然后判断这个变量值确实不小于0才能赋值给ProgressBar1.Value
要么你在每次前先给ProgressBar1.Value 赋初值,以确保ProgressBar1.Value - 2不会产生负数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询