?
Solved

Select Case (greater than number)

Posted on 2005-03-14
9
Medium Priority
?
1,281 Views
Last Modified: 2012-05-05
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
Comment
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
9 Comments
 
LVL 6

Expert Comment

by:BubbaisBest
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

by:justinbillig
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

by:jrram
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:BubbaisBest
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

by:NeoTeq
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

by:engineroom
ID: 13538543
neoTeg, is this right?

select case true?
0
 
LVL 10

Accepted Solution

by:
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

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

Author Comment

by:engineroom
ID: 13538773
thanx, that's great!

dj
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…

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.

Join & Ask a Question