show form random location

eddyman

New member
Joined
May 26, 2009
Messages
2
Programming Experience
Beginner
ok some im working on a little project and i need my form1 to basiclly spam itself in random locations...is this possible?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,322
Location
Sydney, Australia
Programming Experience
10+
That doesn't make sense. You want your form to send itself unsolicited bulk email? How about you provide a FULL and CLEAR description of what you're trying to achieve? We only know what you tell us, so tell us everything that's relevant.
 

eddyman

New member
Joined
May 26, 2009
Messages
2
Programming Experience
Beginner
no what i mean is... my friend made a progrma that when opened it will open form1 in random locations at a 2 second interval...im trying to do that so far ive tried useing to forms and using the form1.Show code but it load to fast...im trying to use the timer but dont know how it works
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,322
Location
Sydney, Australia
Programming Experience
10+
no what i mean is... my friend made a progrma that when opened it will open form1 in random locations at a 2 second interval...im trying to do that so far ive tried useing to forms and using the form1.Show code but it load to fast...im trying to use the timer but dont know how it works
That's a far more precise explanation of what you want to do. Please provide that sort of explanation in the first post in future threads.

Add a Timer to your form and set its Interval property to 2000 (milliseconds). Set the Enabled property of the Timer to True or else call its Start method in your form's Load event handler. Double-click the Timer to create a Tick event handler. In that event handler you will set the Location property of the form to a Point created from two Random values for the X and Y components.

To generate random values you pretty much always use a Random object. Declare a member variable and assign a new Random object to it. You call the Next method of the Random object and specify a minimum and maximum for the range of the result. You need to do a little bit of maths to determine those values. You will use the Width and Height of the form along with the Width and Height of your screen area, which you can get from the Screen.WorkingArea property.
 

capedech

Well-known member
Joined
Oct 29, 2008
Messages
62
Programming Experience
Beginner
ok some im working on a little project and i need my form1 to basiclly spam itself in random locations...is this possible?
spam ?? Did u mean 'spawn' ?
Use timer, set to 2 seconds interval (2000).
And use random function.

Peace Out.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,322
Location
Sydney, Australia
Programming Experience
10+
Use timer, set to 2 seconds interval (2000).
And use random function.
If only I'd thought of that... two days ago. ;)

By the way, Random is a class. Next is the Function.
 
Top Bottom