Results 1 to 2 of 2

Thread: [2005] Moving controls randomly

  1. #1

    Thread Starter
    Lively Member James Bearss's Avatar
    Join Date
    Jun 2007
    Location
    USA, Wisconsin
    Posts
    120

    [2005] Moving controls randomly

    How would make a label move throughout a form randomly?
    I like doing magic tricks, and I program in Visual Basic (Duh)

    Download my garage sale helper at
    http://www.vbforums.com/showthread.p...96#post3040996

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Moving controls randomly

    You would randomly select two Integers, create a Point and assign that to the control's Location property, e.g.
    vb.net Code:
    1. Private rand As New Random
    2.  
    3. Private Sub Timer1_Tick(ByVal sender As System.Object, _
    4.                         ByVal e As System.EventArgs) Handles Timer1.Tick
    5.     Dim clientSize As Size = Me.ClientSize
    6.  
    7.     Me.Label1.Location = New Point(rand.Next(0, clientSize.Width - Me.Label1.Width), _
    8.                                    rand.Next(0, clientSize.Height - Me.Label1.Height))
    9. End Sub
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width