473,587 Members | 2,580 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 1256
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******** *************** ***********@59g 2000hsb.googleg roups.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******** *************** ***********@59g 2000hsb.googleg roups.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.comschri eb:
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
14127
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 appropriate document, or post an example? I don't relish the idea especially long if-else statements. Joe
12
5164
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
1281
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. Why are there no C++ equivalents to C#'s detailed formatting options? In the following code block, the editor won't *accept* a tab before the case...
15
1543
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
6204
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 statement. pOrder as input value where pOrder can be 1 or 0
1
1267
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 Staff Writer 5:27 PM PST, January 25, 2007 WASHINGTON -- Vice President Dick Cheney and his former chief of staff, I. Lewis "Scooter" Libby, were...
17
2637
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
13172
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 ridiculous (eg. the 16 ways of writing my name) and, in some cases, frightening. Is it to avoid having to think up new identifiers? And how would...
13
11797
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 just curious to find out is it effective to use this method?? or is there is any other alternative method present so that execution time and code size...
0
7918
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8206
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5713
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1185
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.