473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Case with more options

Hi,
I have a particular need and I tryed to use this code:

Select Case i
Case 1 or 100
Istructions 1
Case 2 or 100
Istructions 2
Case 3 or 100
Istructions 3
End Select

In deep I need that:
if i=1 or 2 or 3 i need to execute the single instruction contained in
a single case.
If i=100 i need to execute all instruction.
This code does not work, any suggestions?

Thanks
Mar 17 '08 #1
4 1251
How about this:
Select Case i
Case 1
Istructions 1
Case 2
Istructions 2
Case 3
Istructions 3
Case 100
Istructions 1
Istructions 2
Istructions 3
End Select
?

vovan

"Marcolino" <ma************@gmail.comwrote in message
news:35**********************************@59g2000h sb.googlegroups.com...
Hi,
I have a particular need and I tryed to use this code:

Select Case i
Case 1 or 100
Istructions 1
Case 2 or 100
Istructions 2
Case 3 or 100
Istructions 3
End Select

In deep I need that:
if i=1 or 2 or 3 i need to execute the single instruction contained in
a single case.
If i=100 i need to execute all instruction.
This code does not work, any suggestions?

Thanks

Mar 17 '08 #2
Hi,

it would be more like this:

Rather than using Select Case, I would use 3 If...Then statements.

If i = 1 OrElse i = 100 Then
Instructions 1
End If

If i = 2 OrElse i = 100 Then
Instructions 2
End If

If i = 3 OrElse i = 100 Then
Instructions 3
End If

On 17.03.2008 20:56, vovan wrote:
How about this:
Select Case i
Case 1
Istructions 1
Case 2
Istructions 2
Case 3
Istructions 3
Case 100
Istructions 1
Istructions 2
Istructions 3
End Select
?

vovan

"Marcolino" <ma************@gmail.comwrote in message
news:35**********************************@59g2000h sb.googlegroups.com...
>Hi,
I have a particular need and I tryed to use this code:

Select Case i
Case 1 or 100
Istructions 1
Case 2 or 100
Istructions 2
Case 3 or 100
Istructions 3
End Select

In deep I need that:
if i=1 or 2 or 3 i need to execute the single instruction contained in
a single case.
If i=100 i need to execute all instruction.
This code does not work, any suggestions?

Thanks

Mar 17 '08 #3
"Marcolino" <ma************@gmail.comschrieb:
Select Case i
Case 1 or 100
Istructions 1
Case 2 or 100
Istructions 2
Case 3 or 100
Istructions 3
End Select

In deep I need that:
if i=1 or 2 or 3 i need to execute the single instruction contained in
a single case.
If i=100 i need to execute all instruction.
This code does not work, any suggestions?
\\\
Select Case i
Case 1, 2, 3
Instructions
Case 100
Instructions
End Select
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Mar 17 '08 #4
Herfried,

I had expected more from you

:-)

I would go for the three if's or easier the case where the one for 100 was
including a method to do instructions 1, 2 and 3

Cor

Mar 18 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
14108
by: Joe Stevenson | last post by:
Hi all, I skimmed through the docs for Python, and I did not find anything like a case or switch statement. I assume there is one and that I just missed it. Can someone please point me to the...
12
5151
by: Phoe6 | last post by:
The Program Fragment is this: int choice; /* Users Input Command */ .. .. .. printf("Enter a command: "); fflush(stdin); choice = getc(stdin); printf("\n");
1
1280
by: _DG | last post by:
Re VS2005 editor in Emacs mode (options->env->keyboard mapping) First of all, there are very few editor options for formatting C/C++ code. Only three option pages. C# has about 10, I believe....
15
1535
by: gregory_may | last post by:
Is there any options in VS 2005 to better handle case issues in C# (Similar to VB.Net)?
7
6174
by: mandible | last post by:
Hello I'm trying to have some control on how my data is ordered depending on an input parameter my question is in a stored procedure how can I do something like this at the end of my...
1
1263
by: thermate | last post by:
http://www.latimes.com/news/nationworld/nation/la-na-libby26jan26,1,2730931.story?coll=la-headlines-nation Aide testifies Cheney helped effort to discredit Wilson By Richard B. Schmitt, Times...
17
2623
by: Navodit | last post by:
So I have some code like: if (document.Insurance.State.selectedIndex == 1) { ifIll(); } else if (document.Insurance.State.selectedIndex == 2) { elseKan(); }
38
13155
by: Bart | last post by:
Why is C case sensitive? I know it's a bit late to change it now but there would seem to be far more advantages in ignoring letter case in source code. In real life such a situation would be...
13
11771
by: Satya | last post by:
Hi everyone, This is the first time iam posting excuse me if iam making any mistake. My question is iam using a switch case statement in which i have around 100 case statements to compare. so...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.