473,466 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

select case question

Hi

I am converting a app from VB6 to C# and I was wondering if anyone can tell
me how to implement the following in c#
case 207 To 252

Thanks in advance


Nov 16 '05 #1
3 2164
Hi Starbuck,

You can use an if/else if/else statement, similar to this:

if (val >= 0 && val <= 206)
{
// your code
}
else if (val >= 207 && val <= 252)
{
}
//...more else ifs
else
{
// when nothing else matches
}

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
C# Tutorial - www.csharp-station.com

"Starbuck" <st******@mbssoft.co.uk> wrote in message
news:e3**************@tk2msftngp13.phx.gbl...
Hi

I am converting a app from VB6 to C# and I was wondering if anyone can tell me how to implement the following in c#
case 207 To 252

Thanks in advance



Nov 16 '05 #2
You could also do this:

switch (val) {
case 207:
case 208:
case 209:
// ... more cases here
case 252:
// your code here
// break;
}

Obviously it's not terribly practical for a range of that many cases, and
if/elseif ... /else would be more sensible. But the above works for those
times when you have a handful of cases that need to run the same code.

--Bob

"Joe Mayo [C# MVP]" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:ey**************@TK2MSFTNGP11.phx.gbl...
Hi Starbuck,

You can use an if/else if/else statement, similar to this:

if (val >= 0 && val <= 206)
{
// your code
}
else if (val >= 207 && val <= 252)
{
}
//...more else ifs
else
{
// when nothing else matches
}

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
C# Tutorial - www.csharp-station.com

"Starbuck" <st******@mbssoft.co.uk> wrote in message
news:e3**************@tk2msftngp13.phx.gbl...
Hi

I am converting a app from VB6 to C# and I was wondering if anyone can

tell
me how to implement the following in c#
case 207 To 252

Thanks in advance




Nov 16 '05 #3
Thanks guys

"Bob Grommes" <bo*@bobgrommes.com> wrote in message
news:uu**************@TK2MSFTNGP09.phx.gbl...
You could also do this:

switch (val) {
case 207:
case 208:
case 209:
// ... more cases here
case 252:
// your code here
// break;
}

Obviously it's not terribly practical for a range of that many cases, and
if/elseif ... /else would be more sensible. But the above works for those
times when you have a handful of cases that need to run the same code.

--Bob

"Joe Mayo [C# MVP]" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:ey**************@TK2MSFTNGP11.phx.gbl...
Hi Starbuck,

You can use an if/else if/else statement, similar to this:

if (val >= 0 && val <= 206)
{
// your code
}
else if (val >= 207 && val <= 252)
{
}
//...more else ifs
else
{
// when nothing else matches
}

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
C# Tutorial - www.csharp-station.com

"Starbuck" <st******@mbssoft.co.uk> wrote in message
news:e3**************@tk2msftngp13.phx.gbl...
Hi

I am converting a app from VB6 to C# and I was wondering if anyone can

tell
me how to implement the following in c#
case 207 To 252

Thanks in advance





Nov 16 '05 #4

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

Similar topics

3
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
2
by: JMCN | last post by:
hello i have your basic select case question. i created a combo box and save it as a query. so whenever the user selects the value and clicks the export button, the select case should then export...
7
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
16
by: ME | last post by:
In C# the following code generates a compiler error ("A constant value is expected"): public void Test(string value) { switch (value) { case SimpleEnum.One.ToString(): MessageBox.Show("Test...
6
by: mabond | last post by:
Hi Is it possible to compare a vaule for a select case statement using a wildcard. e.g. somthing like Select case myValue case like "*ing" end select
4
by: Michel | last post by:
Hi, How can I use then Windows' color picker from Access? Thx
6
by: Spam Catcher | last post by:
Does anyone know why this doesn't work: Select Case X Case X or Y msgbox("hello world!") End Select It seems X or Y doesn't evaluate correctly (I think only the first 1/2 is
21
beacon
by: beacon | last post by:
Hello to everybody, I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know),...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
1
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...
0
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...
0
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,...
0
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.