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?
 
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.
 
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
 
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.
 
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.
 
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.
 
Back
Top