Public Class Form2
Dim xi As Integer, yi As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim x As Single, y As Single
x = PictureBox1.Location.X
y = PictureBox1.Location.Y
If x > Me.Width - PictureBox1.Width - 16 Or x < 0 Then
xi = -xi
End If
If y > Me.Height - PictureBox1.Height - Me.Icon.Height - 6 Or y < 0 Then
yi = -yi
End If
x = x + xi
y = y + yi
PictureBox1.Location = New Point(x, y)
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer1.Interval = 30
xi = 1
yi = 1
End Sub
End Class
要算form的边框和标题栏