[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 555
  • Last Modified:

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
1 Solution
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 ?

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now