-
Nov 5th, 2016, 06:37 AM
#1
Thread Starter
PowerPoster
[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!!
-
Nov 5th, 2016, 08:26 AM
#2
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
-
Nov 5th, 2016, 11:51 AM
#3
Thread Starter
PowerPoster
Re: [RESOLVED] Make "snow" appear on form?
-
Nov 5th, 2016, 05:32 PM
#4
Hyperactive Member
Re: [RESOLVED] Make "snow" appear on form?
Last edited by I Love VB6; Nov 5th, 2016 at 05:43 PM.
-
Nov 5th, 2016, 05:43 PM
#5
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|