best way to float and move randomly a picture on top of a vb6 form

i am trying to determine how to float move randomly a picture on top of a form. should i use a picturebox or another borderless form or maybe even a child form. Once i determine the best way I will post another question on how to randomly move it and keep it within the boundaries of the form it is over
Who is Participating?
In VB6, the picturebox is the best way to go. It's light-weight but still has a full range of properties you can play with. There's a property to remove the 3D-style inset border, I think it's the BorderStyle property.

Once you've placed the picturebox on the form, you can use a timer to move it around periodically. Hook into the timer object's Tick event, and change the picturebox's Left and Top properties.

Since the left and top properties control the pixel coordinates where the left and top edges of the box are respectively, so the valid range while keeping the picturebox inside the form is:

X range:     0 to (Form1.width-Picturebox1.width)
Y range:     0 to (Form1.height-Picturebox1.height)

You can generate coordinates randomly using the Rnd() function and a bit of math.
isnoend2001Author Commented:
Thanks for adding that got it to work, but having trouble making it smooth it's kinda jerky.
Any ideas ?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.