|
Post by Dynamic Sysop on Jun 8, 2003 8:03:38 GMT -5
in vb6 / .net you use Select Case , in C# / C++ we use Switch , here's an example in C# . i think C++ is pretty much the same
private void button3_Click(object sender, System.EventArgs e) { for (int x=0; x!=6; x++)// count from 0 to 5 { you can use x<6 also } { switch(x) { case 0:this.Text="starting count";//form's caption break; case 1:MessageBox.Show("number1"); break; case 2:MessageBox.Show("number2"); break; case 3:MessageBox.Show("number3"); break; case 4:MessageBox.Show("number4"); break; case 5:this.Text="done counting";//update form's caption break; } }
}
|
|
Trad
New Member
Posts: 1,122
|
Post by Trad on Jun 8, 2003 11:05:54 GMT -5
Yes, quite simela.
this is how it would be (precisely) in C++
//int random is a random number between 1 and 5
void ReadNumber(int random) { MessageBox(NULL,"This Function Tells You The Value Of random","Info",MB_OK); switch (random) { case 1[img]http://proboards8.com/boardimages/sad.gif[/img]br]MessageBox(NULL,"The Value Of random Is 1","Result",MB_OK); break; case 2[img]http://proboards8.com/boardimages/sad.gif[/img]br]MessageBox(NULL,"The Value Of random Is 2","Result",MB_OK); break; case 3[img]http://proboards8.com/boardimages/sad.gif[/img]br]MessageBox(NULL,"The Value Of random Is 3","Result",MB_OK); break; case 4[img]http://proboards8.com/boardimages/sad.gif[/img]br]MessageBox(NULL,"The Value Of random Is 4","Result",MB_OK); break; case 5[img]http://proboards8.com/boardimages/sad.gif[/img]br]MessageBox(NULL,"The Value Of random Is 5","Result",MB_OK); default[img]http://proboards8.com/boardimages/sad.gif[/img]br]MessageBox(NULL,"The Value Of random Is Unknown","Error",MB_OK); } }
|
|