Public start As BooleanPrivate Sub Command4_Click()
start=false
Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
start = True
Timer1.Interval = 1000
Shape14.Height = 10
Do While start = True
If Shape14.Height > 2000 Or start = False Then
Exit Do
Timer1.Enable = Flase
Else
Shape14.Height = Shape14.Height + 10
End If
Loop
End Sub
我想用一个按钮控制一个Start=Ture 进入这个状态shape14的高度就增加10每秒 一旦高度过2000或者start信号=false就停止增加高度...程序哪里有问题了?

解决方案 »

  1.   

    去掉Shape14.Height = 10
    和 do/while
      

  2.   

    Exit Do
    Timer1.Enable = Flase
    改成:
    Timer1.Enable = Flase
    Exit Do既然都Exit Do了 后面的Timer1.Enable = Flase就不起作用了
      

  3.   

    另外:Enable应为:Enabled 少了一个D
      

  4.   

    现在代码是有问题的 我点 command4都没反应
      

  5.   

    可能的原因是你没有初始化Timer1.Interval Command4改成:Private Sub Command4_Click()
    start=false
    Timer1.Interval=1000            '添加这句
    Timer1.Enabled = True
    End Sub然后Timer3中的这句就可以去掉
      

  6.   

    多谢谢楼上 还有个问题 我想要 shape14.height<2000 每一次高度变化都要可见 而不是只有最后的高度结果,请问应该怎么写呢? 开始高度是 10 10+10=20这是高度显示20 20+10=30这时高度要显示30...
      

  7.   

    Private Sub Command4_Click()
        Timer1.Enabled = True
        Timer1.Interval = 1000 '这个直接在窗体是设置就可以了
        Shape14.Height = 100
    End SubPrivate Sub Timer1_Timer()
        If Shape14.Height < 2000 Then
            Shape14.Height = Shape14.Height + 100
            Shape14.Top = Shape14.Top - 100 '应该向上增长吧,你的是向下长......
        Else
            Timer1.Enabled = False
        End If
    End Sub
      

  8.   


    Public start As Boolean
    Private Declare Function GetTickCount Lib "kernel32" () As LongPrivate Sub Command4_Click()
    start = False
    Timer1.Interval = 1000
    Timer1.Enabled = True
    Command1.Enabled = False
    End SubPrivate Sub Timer1_Timer()
       Dim lngBeginTickCount As Long
       
        lngBeginTickCount = GetTickCount
        lngTime = Timer()
        Timer1.Enabled = False
        start = True
        Shape14.Height = 10
        Do While start = True
            If Shape14.Height > 2000 Or start = False Then
               
            Exit Do
            Timer1.Enabled = False
            
            Else
            Shape14.Height = Shape14.Height + 10
            Do Until GetTickCount - lngBeginTickCount > 2             '2毫秒刷新一次
               ' DoEvents
            Loop
            lngBeginTickCount = GetTickCount
        End If
        Loop
    End Sub
      

  9.   

    其实不需要TimerPublic start As Boolean
    Private Declare Function GetTickCount Lib "kernel32" () As LongPrivate Sub Command4_Click()
    start = FalseCall ShowShapeEnd Sub
    Private Sub ShowShape()
        Dim lngBeginTickCount As Long
       
        lngBeginTickCount = GetTickCount
        lngTime = Timer()
        Timer1.Enabled = False
        start = True
        Shape14.Height = 10
        Do While start = True
            If Shape14.Height > 2000 Or start = False Then
               
            Exit Do
            Timer1.Enabled = False
            Else
            Shape14.Height = Shape14.Height + 10
            Do Until GetTickCount - lngBeginTickCount > 2             '2毫秒刷新一次
               ' DoEvents
            Loop
            lngBeginTickCount = GetTickCount
        End If
        Loop
    End Sub
      

  10.   

    很多没用的都去掉:Private Declare Function GetTickCount Lib "kernel32" () As Long
    Private Sub Command4_Click()
        Call ShowShape
    End Sub
    Private Sub ShowShape()
        Dim lngBeginTickCount As Long
       
        lngBeginTickCount = GetTickCount
        Shape14.Height = 10
        Do While True
            If Shape14.Height > 2000 Then
                Exit Do
            Else
                Shape14.Height = Shape14.Height + 10
                Do Until GetTickCount - lngBeginTickCount > 2             '2毫秒刷新一次
                    ' DoEvents
                Loop
                lngBeginTickCount = GetTickCount
            End If
        Loop
    End Sub
      

  11.   


    Private Sub Form_Load()
        Timer1.Interval = 1000
        Shape14.Height = 10
    End SubPrivate Sub Command4_Click()
        Timer1.Enabled = Not Timer1.Enabled
    End SubPrivate Sub Timer1_Timer()
       With Shape14
          If .Height > 2000 Then
             Timer1.Enabled = False
          Else
             .Height = .Height + 10
          End If
       End With
    End Sub
      

  12.   

    Private Sub Command4_Click()
    Timer1.Enabled = True
    Timer1.Interval = 1000
    Shape14.Height = 10End Sub
    Private Sub Timer1_Timer()
    If Shape14.Height > 2000 Then
    Timer1.Enable = Flase
    Else
    Shape14.Height = Shape14.Height + 10
    End If
    End Sub
      

  13.   

    Public start As Boolean
    Private Sub Command4_Click()
      Timer1.Enabled = True
      Timer1.Interval = 1000
      Shape14.Height = 10
    End SubPrivate Sub Timer1_Timer()
      If Shape14.Height > 2000 Then
        Timer1.Enable = Flase
      Else
        Shape14.Height = Shape14.Height + 10
      End If
    End Sub
      

  14.   

    '你的DO WHILE 。LOOP语法用错了,应该是START=FALSE ,不然就用 DO UNTIL LOOP
    ,应该你那大体的错误就是这样
      

  15.   

    Shape14.Height = 10
    去掉这个