|
-
Sep 14th, 2009, 08:32 AM
#1
Thread Starter
Addicted Member
-
Sep 14th, 2009, 09:05 AM
#2
Re: Move picturebox randomly....
See if this helps:
New StdExe proj, picturebox, timer
Code:
Option Explicit
Private FW As Long, FH As Long 'form dims
Private PW As Long, PH As Long 'pic dims
Private PL As Long, PT As Long 'pic curr pos
Private Sub Form_Load()
PW = Picture1.ScaleWidth
PH = Picture1.ScaleHeight
PL = Picture1.Left
PT = Picture1.Top
Randomize
Timer1.Interval = 5 'adjust for desired effect
End Sub
Private Sub Form_Resize()
FW = ScaleWidth
FH = ScaleHeight
End Sub
Private Function GetRnd(L As Long, H As Long) As Long
GetRnd = Int((H - L + 1) * Rnd + L)
End Function
Private Sub Timer1_Timer()
Static CL As Long
PL = PL + 75 'adjust for desired effect
Picture1.Left = PL
Picture1.Top = PT
If PL > FW Then
PL = -PW
PT = GetRnd(0, FH - PH)
End If
End Sub
-
Sep 14th, 2009, 10:01 AM
#3
Thread Starter
Addicted Member
Re: Move picturebox randomly....
Exactly what I was looking for. Cheers....
"And then one day you find, ten years have got behind you.
No one told you when to run, you missed the starting gun."
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
|