Private Sub Form_Load()
Shape1.Height = 2000
Shape1.Width = 1500
Shape1.Top = 200
Shape1.Left = 200
Shape2.Height = 1800
Shape2.Width = 1500
Shape2.Top = 400
Shape2.Left = 200
Shape2.FillColor = RGB(255, 255, 0)
Shape2.FillStyle = 0
Timer1.Enabled = True
Timer1.Interval = 1000
End SubPrivate Sub Timer1_Timer()
For i = 0 To 10
If Shape2.Height <= 0 Then
T = MsgBox("倾倒结束!", vbOKOnly, "倾倒提示")
Exit For
Else
Shape2.Height = Shape2.Height - 20
Shape2.Top = Shape2.Top + 20
End If
Next
End Sub
现在当shape2.height<=0时候并不msgbox而是出现 时实错误'380' 无效属性值 按调试就提示这段错误,Shape2.Height = Shape2.Height - 20 请问为什么?shape2高1800应该可以exit for 啊 为什么出错呢?

解决方案 »

  1.   

    Private Sub Timer1_Timer()
    on error goto errproc:
    For i = 0 To 10
    If Shape2.Height <= 0 Then
    T = MsgBox("倾倒结束!", vbOKOnly, "倾倒提示")
    Exit For
    Else
    Shape2.Height = Shape2.Height - 20
    Shape2.Top = Shape2.Top + 20
    End If
    Next
    exit sub
    errproc:
    Shape2.Height = 0
    call MsgBox("倾倒结束!", vbOKOnly, "倾倒提示")
    End Sub因为height不能小于0
      

  2.   

    应该怎么改呢?改成
    For i = 0 To 10
    If Shape2.Height >= 0 Then
    Shape2.Height = Shape2.Height - 20
    Shape2.Top = Shape2.Top + 20
    Else
    Exit For
    T = MsgBox("倾倒结束!", vbOKOnly, "倾倒提示")
    End If
    Next
    还是那个提示啊
      

  3.   

    2楼哥们的代码... MSGBOX出个没完 害我 结束了VB的任务...
      

  4.   

    If Shape2.Height <= 0 Then
    改成
    If Shape2.Height < 20 Then
    就好了,奇怪ING...