# Moving StarField Form BG (3D Version)

This is a really cool form effect, it looks like a starfield moving from the middle of the screen out at you, it kind of looks like the Windows screen saver.

This is not originally my code, but i like it so much that i have made a better version of it. You can change the speed and color of the field. This is an update of my last submission. Enjoy.

Original Author: Adam Lane

- Create a form and a timer
- Form1 and Timer1
- Copy this code into your form

`Dim X(50), Y(50), xSpeed(50), ySpeed(50) As Integer`

Private Sub Form_Load()

Dim i As Integer

Timer1.Interval = 4

Form1.BackColor = vbBlack

Form1.ForeColor = vbBlack

Form1.FillColor = vbBlack

For i = 0 To 49

X(i) = -1

Y(i) = -1

Next i

Randomize

Timer1.Enabled = True

End Sub

Private Sub Timer1_Timer()

Dim i As Integer

For i = 0 To 49

PSet (X(i), Y(i)), &H0&

If X(i) < 0 Or X(i) > Form1.ScaleWidth Or Y(i) < 0 Or Y(i) > Form1.ScaleHeight Then

X(i) = Form1.ScaleWidth 2

Y(i) = Form1.ScaleHeight 2

xSpeed(i) = Int(Rnd(1) * 200) - 100

ySpeed(i) = Int(Rnd(1) * 200) - 100

End If

X(i) = X(i) + xSpeed(i)

Y(i) = Y(i) + ySpeed(i)

PSet (X(i), Y(i)), &HFFFFFF

Next i

End Sub

Loading Comments ...

## Comments

No comments have been added for this post.

*You must be logged in to make a comment.*