|
-
December 16th, 2002, 08:52 PM
#1
switch Simple problem ?
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
-
December 17th, 2002, 03:29 AM
#2
I think u need a default case
switch(number)
{
case 1:
.....
break;
case 2:
.....
break;
case 3:
.....
break;
default:
break;
}
/Anders
-
December 17th, 2002, 04:06 AM
#3
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
"Hhmn... You are damned if you do; and you are damned if you don't." -- bart simpson
-
December 17th, 2002, 12:16 PM
#4
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.
-
December 17th, 2002, 12:20 PM
#5
Re: switch Simple problem ?
Originally posted by pareshgh
tell me what's wrong ?
You are posting incomplete code. See here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|