作者Peruheru (還在想)
看板Visual_Basic
標題Re: [VB2008] 如何讓圖片停留在某一個位置一段時間 …
時間Fri May 22 00:31:14 2009
※ 引述《j76992001 (人緣有待等)》之銘言:
: Private Sub Button1_Click(ByVal sender As System.Object,
: ByVal e As System.EventArgs) Handles Button1.Click
: Turtle.Left = Turtle.Left + 80
: System.Threading.Thread.Sleep(1)
: Application.DoEvents()
: If RadioButton1.Checked = True Then
: Do While Rabbit.Left < Me.ClientSize.Width
: If Rabbit.Location.X = Tree.Location.X Then
: End If
: Rabbit.Left = Rabbit.Left + 1
: System.Threading.Thread.Sleep(1)
: Application.DoEvents()
: If Turtle.Left = Me.ClientSize.Width Then
: MsgBox("烏龜獲勝", , )
: ElseIf Rabbit.Left = Me.ClientSize.Width Then
: MsgBox("兔子獲勝", , )
: End If
我認為你在獲勝之後就應該要離開迴圈
另外我除了開頭的烏龜左緣+80以後,沒有再看到烏龜移動的訊息
你的烏龜只動一次嗎?還是每次按每次加?
如果是要每次按每次加,那兔子的運算就應該放到別處吧?
你得寫法我實在很不容易理解
單純得把兔子放到一個計時器裡面不好嗎?
為什麼要用特異得寫法呢?
: Loop
: End If
: End Sub
: 這是目前全部的程式碼~"~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.163.42
推 j76992001:恩恩 我用Timer寫看看 感謝P大的幫忙 05/22 00:33
推 foliyo:我有做過賽馬的,建議牽扯到需要移動的 都用timer會簡單一些 05/23 20:10
→ lchwzu:用Timer的確會讓它變得簡單些 05/27 10:32