Private Sub Command1_Click()
    Static i As Long
    i=i+1;
    MsgBox(i)
End Sub

解决方案 »

  1.   

    那并不是分号的问题。静态变量只能用在过程内部,用在其他地方就会发生“无效的外部过程调用”错误。
    正确:
    Private Sub Command1_Click()
        Static a As Integer
        a = a + 1
        Debug.Print a
    End Sub错误:
    Static a As Integer
    Private Sub Command1_Click()
        a = a + 1
        Debug.Print a
    End Sub
      

  2.   

    呵呵,迟了,不过阿木说得很对,static只能用在过程内部