我刚开始创建一个项目(To The Topic)
错误从这里开始(也许)
第一个按钮代码
Private Sub DeimosButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeimosButton2.Click
State(i)
DeimosButton3.Visible = False
DeimosButton4.Visible = False
End Sub
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
DeimosButton2.Top = DeimosButton2.Top - 1
If DeimosButton2.Location = New Point(22, 54) Then
Timer4.Stop()
DeimosButton2.Enabled = True
End If
End Sub
Private Sub State(ByVal Ref As Integer)
If Ref = 0 Then
Timer4.Start()
DeimosButton2.Enabled = False
i = 1
Else
Timer5.Start()
DeimosButton2.Enabled = False
i = 0
End If
End Sub
Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
DeimosButton2.Top = DeimosButton2.Top + 1
If DeimosButton2.Location = New Point(22, 85) Then
Timer5.Stop()
DeimosButton2.Enabled = True
DeimosButton3.Visible = True
DeimosButton4.Visible = True
End If
End Sub
此第二按钮代码
Private Sub DeimosButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeimosButton3.Click
states(o)
DeimosButton2.Visible = False
DeimosButton4.Visible = False
End Sub
Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
DeimosButton3.Top = DeimosButton3.Top - 1
If DeimosButton3.Location = New Point(22, 54) Then
Timer6.Stop()
DeimosButton3.Enabled = True
End If
End Sub
Private Sub states(ByVal Def As Integer)
If Def = 0 Then
Timer6.Start()
DeimosButton3.Enabled = False
o = 1
Else
Timer7.Start()
DeimosButton3.Enabled = False
o = 0
End If
End Sub
Private Sub Timer7_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer7.Tick
DeimosButton3.Top = DeimosButton3.Top + 1
If DeimosButton3.Location = New Point(22, 116) Then
Timer7.Stop()
DeimosButton3.Enabled = True
DeimosButton2.Visible = True
DeimosButton4.Visible = True
End If
End Sub
问题是当我点击第二个按钮时 但是当我点击第一个按钮时,无论如何 问题:按钮仍然移动到顶部,虽然它已到达位置 有一个解决方案吗?
答案 0 :(得分:0)
你必须改变
DeimosButton3.Location = New Point(22, 116)
到
DeimosButton3.Location.y = 116
这对所有人都有效 为您的所有代码