我正在尝试使用计时器单击按钮时创建动画。这是我的代码:
Private Sub Animate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Animate.Click
Timer.Enabled = True
End Sub
Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
Dim m As Integer = 0
m = m + 1
Select Case m
Case 1
Me.Arrow4.Visible = True
Me.Arrow5.Visible = True
Me.Arrow6.Visible = True
Case 2
Me.Arrow1.Visible = True
Me.Label1.Visible = True
Me.Arrow4.Visible = False
Me.Arrow5.Visible = False
Me.Arrow6.Visible = False
Case 3
Me.Arrow2.Visible = True
Me.Label2.Visible = True
Me.Arrow1.Visible = False
Me.Label1.Visible = False
Case 4
Me.Arrow3.Visible = True
Me.Label3.Visible = True
Me.Arrow2.Visible = False
Me.Label2.Visible = False
End Select
End Sub
第一个案例显示,但不是其余部分。我将计时器的间隔设置为1。
谢谢!
答案 0 :(得分:1)
其他情况永远不会显示,因为您始终在计时器方法的范围内将m
实例化为0。命中案例陈述时,m
将始终为1。如果要保留值,则需要在类级别将m
移到计时器范围之外。当你遇到最后一个案子时,别忘了将m
设置回0。 e.g。
...
Case 4
Me.Arrow3.Visible = True
Me.Label3.Visible = True
Me.Arrow2.Visible = False
Me.Label2.Visible = False
m = 0
...