-3
我剛開始創建這個項目(的話題)
錯誤是開始在這裏(也許)
第一個按鈕代碼VB.Net移動對象[錯誤]
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
問題是,當我點擊第二個按鈕
但是當我點擊第一個按鈕,就是不管。
問題:按鈕仍然移動到頂部,儘管它已經到達位置。
有這個解決方案嗎?
有此計劃的多個邏輯錯誤。當Location.X不是22時,它完全不起作用。當Top屬性太高或太低時,您希望停止測試,因此只能測試Top,而不是Location。花更多時間與調試器。 –
但按鈕1的第一個代碼是工作 –
哦,我知道,不是位置,但位置.Y 謝謝 –