PDA

Click to See Complete Forum and Search --> : Random Location Pictureboxes


tim_l_012
Mar 12th, 2001, 09:12 PM
I want a picturebox to randomly appear anywhere on the screen (within the frame) after my timer's interval has finished. How can I do this??????????

Sastraxi
Mar 12th, 2001, 10:02 PM
[code]
Private Sub Timer1_Timer()
dim XMax
dim YMax

XMax=Frame1.Width - Picture1.Width
YMax=Frame1.Height - Picture1.Height

Randomize
Picture1.Left=int(rnd*xmax)
Randomize
picture1.Top=int(rnd*ymax)

End Sub

plenderj
Mar 13th, 2001, 02:27 AM
If you only want your picturebox to be positioned randomly, you'd also want to stick a


Timer1.Enabled = False


into Sastraxi's code.

- jamie