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

Posted on 2012-08-10
Last Modified: 2012-08-10
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
Question by:isnoend2001
    LVL 31

    Accepted 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.

    Author Closing Comment

    Thanks for adding that got it to work, but having trouble making it smooth it's kinda jerky.
    Any ideas ?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
    User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now