2014-10-03 28 views
-1

我的代碼有什麼問題?我的語法是正確的,邏輯和概念是正確的。 但當我運行該程序並按下按鈕(使面板向上滑動)面板不停止。即使我在計時器中放置了一個條件。VB.NET中滑動效果的面板位置

這是代碼;

Private Sub btn_existing_Click(sender As Object, e As EventArgs) Handles btn_existing.Click 
     timerPanelSlider3.Start() 
     pnl_info1.Enabled = False 
     pnl_options.Enabled = False 
End Sub 

Private Sub timerPanelSlider3_Tick(sender As Object, e As EventArgs) Handles timerPanelSlider3.Tick 
    yy -= 5 
    pnl_existing.Location = New Point(4, yy) 
    'pnl_existing.BringToFront() 

    If pnl_existing.Location.Y = 225 Then 
     timerPanelSlider3.Stop() 
    End If 

End Sub 
+1

那好吧'pnl_existing.Location.Y'決不= 225。請調試您的工作。 – OneFineDay 2014-10-03 16:58:25

+1

您將地點遞減5,但僅測試正好225時停止。如果遞減導致它跨越那個數量呢? – Plutonix 2014-10-03 16:58:32

+0

你是什麼意思@plutonix – Ellis 2014-10-03 17:01:36

回答

0

Location.Y不打225,你可以檢查它是否得到低於225或者改變它的起始位置,以625

Private Sub btn_existing_Click(sender As Object, e As EventArgs) Handles btn_existing.Click 
    timerPanelSlider3.Start() 
    pnl_info1.Enabled = False 
    pnl_options.Enabled = False 
End Sub 

Private Sub timerPanelSlider3_Tick(sender As Object, e As EventArgs) Handles timerPanelSlider3.Tick 
yy -= 5 
pnl_existing.Location = New Point(4, yy) 
'pnl_existing.BringToFront() 

If pnl_existing.Location.Y < 225 Then 
    timerPanelSlider3.Stop() 
End If 

End Sub