Solved

# Select Case (greater than number)

Posted on 2005-03-14
Medium Priority
1,281 Views
hey all, how do i do something like this

num = 12

select case num

case 10

case > 10  <-------- greater than????

end select

I read somewhere that you could use the IS keyword, but that didn't work. Any ideas? Thanx

dj
0
Question by:engineroom
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions
• 3
• 2
• 2
• +2

LVL 6

Expert Comment

ID: 13538452
engineroom,

Hopefully someone can give you an exact answer but I never found anything on this when I looked for it.  So what I did was do my If-Then-Else loop and set a variable to a number. I did then did my case.  I know this is a workaround but that was the only thing I could find.

Bubs
0

LVL 15

Expert Comment

ID: 13538471
DECLARE @intNumber INTEGER

SET @intNumber = 12

SELECT
CASE WHEN
@intNumber = 12
THEN 'Number Equals Twelve'
WHEN @intNumber < 12
THEN 'Number Less than Twelve'
END
0

LVL 13

Expert Comment

ID: 13538483
You can use a series of if.. else if... statements, but you can't do what you're trying with a CASE statement.
0

LVL 6

Expert Comment

ID: 13538484
Here is a snipplet of my code:

If intNum<0 then
intCase = 1
ElseIf ((intNum>=0) AND (intNum<10)) then
intCase = 2
ElseIf ((intNum>=10) AND (intNum<100)) then
intCase = 3
ElseIf intNum >= 100 then
intCase = 4
End If

Select Case intCase
Case 1
' do here if less than 0
Case 2
' do here between 0 and 10
Case 3
' do here between 10 and 100
Case 4
' do here if over 100
End Select

Bubs
0

LVL 10

Expert Comment

ID: 13538512
I got creative when seeing the question, and although plenty of alternatives have been offered, it seemed a waste not to post mine:

<%

n = 2

select case true
case (n = 1)
%>1<%
case (n > 1)
%>2<%
end select

%>
0

LVL 3

Author Comment

ID: 13538543
neoTeg, is this right?

select case true?
0

LVL 10

Accepted Solution

NeoTeq earned 2000 total points
ID: 13538565
yes... you see, I'm checking if true equals to (n > 1), and if n = 2, then (n > 1) will be true (and true = true so the case is true)
0

LVL 6

Expert Comment

ID: 13538573
Excellent NeoTeq...Just what engineroom was needing (as well as myself)...Bubs
0

LVL 3

Author Comment

ID: 13538773
thanx, that's great!

dj
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than oneâ€¦
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/â€¦
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philosâ€¦
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increasedâ€¦
###### Suggested Courses
Course of the Month10 days, 21 hours left to enroll

#### 770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.