Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
AnswerRe: exit event handler Pin
CWIZO15-Oct-06 7:58
CWIZO15-Oct-06 7:58 
AnswerRe: exit event handler Pin
sam#15-Oct-06 8:26
sam#15-Oct-06 8:26 
QuestionContent Base Retrivel of Audio & Vedio Data Pin
Muhammad Chitrali15-Oct-06 6:08
Muhammad Chitrali15-Oct-06 6:08 
AnswerRe: Content Base Retrivel of Audio & Vedio Data Pin
Amar Chaudhary15-Oct-06 15:00
Amar Chaudhary15-Oct-06 15:00 
Questionhow to put text in 50 labels Pin
Yustme15-Oct-06 2:33
Yustme15-Oct-06 2:33 
AnswerRe: how to put text in 50 labels Pin
Anthony Mushrow15-Oct-06 2:57
professionalAnthony Mushrow15-Oct-06 2:57 
GeneralRe: how to put text in 50 labels Pin
Yustme15-Oct-06 3:08
Yustme15-Oct-06 3:08 
GeneralRe: how to put text in 50 labels [modified] Pin
Anthony Mushrow15-Oct-06 3:17
professionalAnthony Mushrow15-Oct-06 3:17 
Hmm, you could do this then:

<br />
Random rnd = new Random();<br />
			<br />
			foreach(Control label in this.Controls)<br />
			{<br />
				if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
				{<br />
					label.Text = rnd.Next(0, 20) + " + " + rnd.Next(0, 20) + " =";<br />
				}<br />
			}<br />


on the rnd.Next part, you have to set the minimum and maximum values (in this case 0 and 20)

If you wanted to include minus questions to could do this:

Random rnd = new Random();<br />
			Random sign = new Random();<br />
			<br />
			foreach(Control label in this.Controls)<br />
			{<br />
				switch(sign.Next(0, 2).ToString())<br />
				{<br />
					case "0":	<br />
						if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
						{<br />
							label.Text = rnd.Next(0, 20) + " + " + rnd.Next(0, 20) + " =";<br />
						}<br />
						break;<br />
						<br />
					case "1":<br />
						if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
						{<br />
							int large = rnd.Next(1, 20); <br />
							int small = rnd.Next(0, 20);<br />
							while(large < small) //make sure that the answer isn't negative, take this out if you don't mind the answer being negative<br />
							{<br />
								small = rnd.Next(0, 20);<br />
							}<br />
						<br />
							label.Text = large + " - " + small + " =";<br />
						}<br />
						break;<br />
				}<br />
			}


And use a switch to change between + or -



-- modified at 9:30 Sunday 15th October, 2006
GeneralRe: how to put text in 50 labels Pin
Yustme15-Oct-06 3:31
Yustme15-Oct-06 3:31 
GeneralRe: how to put text in 50 labels Pin
Anthony Mushrow15-Oct-06 3:48
professionalAnthony Mushrow15-Oct-06 3:48 
GeneralRe: how to put text in 50 labels Pin
Yustme15-Oct-06 4:11
Yustme15-Oct-06 4:11 
GeneralRe: how to put text in 50 labels Pin
Yustme15-Oct-06 10:01
Yustme15-Oct-06 10:01 
GeneralRe: how to put text in 50 labels Pin
Tim Paaschen15-Oct-06 20:55
Tim Paaschen15-Oct-06 20:55 
GeneralRe: how to put text in 50 labels Pin
Yustme16-Oct-06 0:24
Yustme16-Oct-06 0:24 
QuestionSending data via IP or MAC address - help [modified] Pin
Anthony Mushrow15-Oct-06 2:18
professionalAnthony Mushrow15-Oct-06 2:18 
AnswerRe: Sending data via IP or MAC address - help Pin
Rob Graham15-Oct-06 3:46
Rob Graham15-Oct-06 3:46 
GeneralRe: Sending data via IP or MAC address - help Pin
Anthony Mushrow15-Oct-06 3:53
professionalAnthony Mushrow15-Oct-06 3:53 
GeneralRe: Sending data via IP or MAC address - help Pin
Nader Elshehabi15-Oct-06 6:00
Nader Elshehabi15-Oct-06 6:00 
QuestionSimple Threading headache Pin
XTr1NiTy14-Oct-06 22:00
XTr1NiTy14-Oct-06 22:00 
AnswerRe: Simple Threading headache Pin
Corinna John14-Oct-06 23:43
Corinna John14-Oct-06 23:43 
GeneralRe: Simple Threading headache Pin
XTr1NiTy15-Oct-06 0:08
XTr1NiTy15-Oct-06 0:08 
QuestionProblem ion Creating XML FIles Pin
farhan197614-Oct-06 21:37
farhan197614-Oct-06 21:37 
AnswerRe: Problem ion Creating XML Files Pin
Larantz15-Oct-06 3:06
Larantz15-Oct-06 3:06 
QuestionHow can I list all functions in a Win32 dll? Pin
Igor Lima14-Oct-06 20:50
Igor Lima14-Oct-06 20:50 
AnswerRe: How can I list all functions in a Win32 dll? Pin
Corinna John14-Oct-06 22:36
Corinna John14-Oct-06 22:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.