Results 1 to 5 of 5

Thread: [RESOLVED] Make "snow" appear on form?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Resolved [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:
    1. Dim x(150), y(150), ptimer
    2.  
    3. Private Sub Form_KeyPress(KeyAscii As Integer)
    4. If KeyAscii = 27 Then
    5. Unload Me
    6. End If
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10. Form1.Width = 15360
    11. For Var = 0 To 150
    12. x(Var) = Form1.ScaleHeight * Rnd
    13. y(Var) = Form1.ScaleWidth * Rnd
    14. Form1.Circle (x(Var), y(Var)), 10, QBColor(15)
    15. Next Var
    16. End Sub
    17.  
    18. Private Sub Snow_Timer()
    19. If Timer < ptimer + 0.01 Then Exit Sub
    20. Form1.Cls
    21.  
    22. For Var = 0 To 150
    23. 'x(Var) = Form1.ScaleHeight * Rnd
    24. 'y(Var) = Form1.ScaleWidth * Rnd
    25. s = Int(Rnd * 50)
    26. x(Var) = Val(x(Var) + s)
    27. r = Int(Rnd * 50)
    28. y(Var) = Val(y(Var) + r)
    29. If x(Var) > Form1.ScaleHeight Then
    30. x(Var) = -1
    31. End If
    32. If y(Var) > Form1.ScaleWidth Then
    33. y(Var) = -1
    34. End If
    35. Form1.Circle (x(Var), y(Var)), 15, QBColor(15)
    36. ptimer = Timer
    37. Next
    38. 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!!

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    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

    Code:
    Dim var as Integer

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: [RESOLVED] Make "snow" appear on form?

    Thank you!

  4. #4
    Hyperactive Member
    Join Date
    Oct 2016
    Posts
    369

    Re: [RESOLVED] Make "snow" appear on form?

    See next post
    Last edited by I Love VB6; Nov 5th, 2016 at 05:43 PM.

  5. #5
    Hyperactive Member
    Join Date
    Oct 2016
    Posts
    369

    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
  •  



Click Here to Expand Forum to Full Width