Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Simple code on how to make any picture bounce arou...
Author:
JD
E-mail:
Click to e-mail author
Submitted:
7/4/2002
Version:
VB6
Compatibility:
VB6
Category:
Screen Savers
Views:
23154
Simple code on how to make any picture bounce around the screen using timers and screen.width and screen.height.
Declarations:
' Put a picturebox and 4 timers on the form. ' Put your picture in the picture box properties and ' make sure it fits the picture box. ' Set the timer intervals to 1 Public X, Y
Code:
Private Sub Form_Click() End End Sub Private Sub Form_Load() Form1.WindowState = vbMaximized Picture1.Left = Screen.Width / 2 - Picture1.Width / 2 Picture1.Top = Screen.Height / 2 - Picture1.Height / 2 Y = 50 X = 50 Timer1.Enabled = True Timer2.Enabled = False Timer3.Enabled = True Timer4.Enabled = False End Sub Private Sub Timer1_Timer() If Picture1.Left > 1 Then Picture1.Left = Picture1.Left - Y Else Timer1.Enabled = False Timer2.Enabled = True End If End Sub Private Sub Timer2_Timer() If Picture1.Left < Screen.Width - Picture1.Width Then Picture1.Left = Picture1.Left + Y Else Timer1.Enabled = True Timer2.Enabled = False End If End Sub Private Sub Timer3_Timer() If Picture1.Top > 1 Then Picture1.Top = Picture1.Top - X Else Timer3.Enabled = False Timer4.Enabled = True End If End Sub Private Sub Timer4_Timer() If Picture1.Top < Screen.Height - Picture1.Height Then Picture1.Top = Picture1.Top + X Else Timer3.Enabled = True Timer4.Enabled = False End If End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement