我的第二個程式氣球

使用物件:

氣球:ovalshape    Fillstyle=solid

按鈕:button x 3   由左而右分別命名為 button1, button2 and button3

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    ball.height = ball.height + 1
    ball.width= ball.width + 1
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    ball.height = ball.height - 1
    ball.width= ball.width - 1
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    ball.height =  1
    ball.width=  1
End Sub

再加點花樣吧(氣球會變跟屁蟲追著滑鼠跑喔!)

把以下這些程式碼剪下貼上,看得懂盡量看,看不懂沒關係,再幾堂課後必須要看得懂!!

Public Class Form1

Dim MyX As Single, MyY As Single

 

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

 

If ball.Top + ball.Height / 2 > MyY Then

    ball.Top = ball.Top - 10

End If

 

If ball.Top + ball.Height / 2 < MyY Then

    ball.Top = ball.Top + 10

End If

 

If ball.Left + ball.Width / 2 > MyX Then

    ball.Left = ball.Left - 10

End If

 

If ball.Left + ball.Width / 2 < MyX Then

    ball.Left = ball.Left + 10

End If

 

End Sub

 

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

  MyY = e.Y

  MyX = e.X

End Sub

End Class


2. 為了熱鬧點,配上音樂後再封裝發行程式

加入Windows Media Player音樂播放的控制項的步驟

(1)指標移到工具箱上按滑鼠右鍵>點選 選擇項目

(2)找到COM元件之Windows Media Player選取之再按確定

(3)工具箱上找到Windows Media Player佈放表單上

(4)將URL設定為你喜歡的音樂檔即可,例如

URL="http://mid.lt263.com/midi/ct/ct4/ct4_3.mid"       (放屁車配樂,超懷念)

 或其他 電玩音樂