Click to See Complete Forum and Search --> : switch Simple problem ?
pareshgh
December 16th, 2002, 07:52 PM
Hi have used a switch the problem
switch ( sTreeText )
{
case "Practice Resource Setup":
...........
break;
case "Practice Time Setup":
break;
case "Quick Buttons":
break;
case "Procedure Code Setup":
break;
}
tell me what's wrong ?
but it says
Control can't fall through from one case label (first case) to another.
thanx
Paresh
Anders Jansson
December 17th, 2002, 02:29 AM
I think u need a default case
switch(number)
{
case 1:
.....
break;
case 2:
.....
break;
case 3:
.....
break;
default:
break;
}
/Anders
owenrb
December 17th, 2002, 03:06 AM
I think you can't do it with string.
According to MSDN: The expression enclosed in parentheses (after the switch statement), the "controlling expression," must be of an integral type or of a class type for which there is an unambiguous conversion to integral type.
I guess you should implement it using nested if-then-else statement and strcmp (string compare) function.
I hope this will help.
Owen
pareshgh
December 17th, 2002, 11:16 AM
the strcmp was in VC++/C/C++. I guess you are a core C++ programmer. thanks for help. but in C# it accepts strings also.
Arild Fines
December 17th, 2002, 11:20 AM
Originally posted by pareshgh
tell me what's wrong ?
You are posting incomplete code. See here (http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8).
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.