[RESOLVED] Make "snow" appear on form?
Hi there folks! Since winter is on the way, I wanted to add some snow to an app for the students. Get them in the Christmas spirit! So, I found a snippet of code on the net..
VB Code:
Dim x(150), y(150), ptimer
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
Unload Me
End If
End Sub
Private Sub Form_Load()
Form1.Width = 15360
For Var = 0 To 150
x(Var) = Form1.ScaleHeight * Rnd
y(Var) = Form1.ScaleWidth * Rnd
Form1.Circle (x(Var), y(Var)), 10, QBColor(15)
Next Var
End Sub
Private Sub Snow_Timer()
If Timer < ptimer + 0.01 Then Exit Sub
Form1.Cls
For Var = 0 To 150
'x(Var) = Form1.ScaleHeight * Rnd
'y(Var) = Form1.ScaleWidth * Rnd
s = Int(Rnd * 50)
x(Var) = Val(x(Var) + s)
r = Int(Rnd * 50)
y(Var) = Val(y(Var) + r)
If x(Var) > Form1.ScaleHeight Then
x(Var) = -1
End If
If y(Var) > Form1.ScaleWidth Then
y(Var) = -1
End If
Form1.Circle (x(Var), y(Var)), 15, QBColor(15)
ptimer = Timer
Next
End Sub
The problem is now that I integrated it, it is saying I need to define "var", but it didn't need to be in the example code by itself?
Where did I go wrong?
Thanks!!
Re: Make "snow" appear on form?
You are probably using Option Explicit. This is a good thing and it requires you to dim all variables.
You should dim Var in each of the two routines where it is used.
In other words you need to add a line to the two subs
Re: [RESOLVED] Make "snow" appear on form?
Re: [RESOLVED] Make "snow" appear on form?
Re: [RESOLVED] Make "snow" appear on form?
It doesn't look like snow to me; just a bunch of circles all the same size. Why don't you use animated gif images instead. Check out the link
http://www.sevenoaksart.co.uk/snow_animations.htm