看板 Visual_Basic 關於我們 聯絡資訊
※ 引述《SKYLYING (好像消息有點慢~"~)》之銘言: : 我是寫一個大砲飛出去的程式 : 現在有個小問題就是 : Private Sub Command1_Click() : Timer1.Interval = 50 : End Sub : Private Sub Command2_Click() : Option1 = False : Option2 = False : Option3 = False : Inptxt.Text = "" : pic1 = Initial : End Sub : Private Sub Timer1_Timer() : Static t As Integer : t = t + 1 : a = Val(Inptxt.Text) : If Option1.Value = True Then : pic2.Left = pic2.Left + a * t : pic2.Top = pic2.Top + 0.5 * 9.8 * t ^ 2 : End If : If Option2.Value = True Then : pic2.Left = pic2.Left + a * t : pic2.Top = pic2.Top + 0.5 * 1.63 * t ^ 2 : End If : If Option3.Value = True Then : pic2.Left = pic2.Left + a * t : pic2.Top = pic2.Top + 0.5 * 30 * t ^ 2 : End If : End Sub : 以上是程式碼 : 可是在command2的地方 : 我想要把整個程式還原成一開始的狀態 : option的部份ok : inptxt的部份也ok : 可是 pic1 也就是砲彈 射出去之後就消失了 要怎麼把它變回來阿= = : 一直不知道怎麼寫他才會變回來 : 先謝謝@@ 其實砲彈並不是不見了,只是他跑出畫面而己。 所以你只要再設定一個條件值(IF) 讓pic1.left或pic1.top小於視窗畫面時,或是操作中止時, 重新再定位一次它們的left跟top即可。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.23.219.131
SKYLYING:感謝^^ 04/08 21:25
sarum10:順便問...位置變回來後t能不能順便歸零呢?? 04/09 07:05
sarum10:已解決ˊˋ 04/09 07:32