473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

case > 1?

Hey, does anyone know how to put this into a switch() statement?

switch(lvLogs.Items.Count)
{

case < 1:

Bitmap myBitmap_Error = new Bitmap(imageList1.Images[0]);

Icon myIcon_Error = Icon.FromHandle(myBitmap_Error.GetHicon());

}

What I want it to do is if lvLogs.Items.Count is less then one, then run my
code. But, It gives me a lot of errors, highlighting "Case < 1". ( ;
exculpated, Invalid expression <, etc.)

Does anyone know how to get around this? Thanks.
Nov 15 '05 #1
2 1804
Donald Smith <St**************@Cox.net> wrote:
Hey, does anyone know how to put this into a switch() statement?


You can't, basically. switch/case is about individual values, not
ranges. You need to use straight if statements otherwise.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
Cases must be specific values of the property specified in the switch, not
expressions or ranges.

You probably need to use if / else along the following lines:

int intCount = lvLogs.Items.Count;

if (intCount < 1) {
// handle Count < 1
} else if (intCount == 2 {
// handle Count == 2
} else if (intCount < 5 {
// handle Count == 3 or 4
} else {
// handle all other cases
}

--Bob

"Donald Smith" <St**************@Cox.net> wrote in message
news:kEK2c.13124$3X2.4466@okepread04...
Hey, does anyone know how to put this into a switch() statement?

switch(lvLogs.Items.Count)
{

case < 1:

Bitmap myBitmap_Error = new Bitmap(imageList1.Images[0]);

Icon myIcon_Error = Icon.FromHandle(myBitmap_Error.GetHicon());

}

What I want it to do is if lvLogs.Items.Count is less then one, then run my code. But, It gives me a lot of errors, highlighting "Case < 1". ( ;
exculpated, Invalid expression <, etc.)

Does anyone know how to get around this? Thanks.

Nov 15 '05 #3

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

Similar topics

0
by: Gabriel Harrison | last post by:
Hi, I know from the MySQL documentation that Windows in not case sensitive and Unix is but can I force Windows to honour upper and lower case in table names. When writing the mySQL on windows...
5
by: Ryan | last post by:
I'm struggling with a Case statement. The problem I has is with doing >= I can use any value in there, but need to check if it's greater or equal to 1. I'm sure I'm missing something but can't...
1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
7
by: C# newbie | last post by:
Hi, How can I make my query to return both "Bob" & "bob" (during search for a string) ? any idea? thanks
10
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
4
by: Mark Rae | last post by:
Hi, Is it possible to create a case-insensitive List<stringcollection? E.g. List<stringMyList = new List<string>; MyList.Add("MyString"); So that:
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.