קוד:
Option Explicit
Dim x%, x1%, y%, y1%, w%, w1%, h%, h1%, d%
Private Sub Form_Load()
'Line Number #1
x = 2
y = 365
h = 20
w = 200
'Line Number #2
x1 = 200
y1 = 2
h1 = 20
w1 = 200
d = 4
Line (x1, y1)-(x1 + w1, y1 + h1), vbBlue, BF
Line (x, y)-(x + w, y + h), vbBlack, BF
End Sub
Private Sub Timer1_Timer()
Line (x1, y1)-(x1 + w1, y1 + h1), Me.BackColor, BF
x1 = x1 + d
If (x1 + w1) >= Me.ScaleWidth Then
x1 = x1 - d
d = -d
ElseIf x1 <= 0 Then
d = -d
x1 = x1 + d
End If
Line (x1, y1)-(x1 + w1, y1 + h1), vbBlue, BF
Line (x1, y1)-(x1 + w1, y1 + h1), vbBlue, BF
End Sub