Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1284

# Select Case (greater than number)

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
engineroom
• 3
• 2
• 2
• +2
1 Solution

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

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

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

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

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

Author Commented:
neoTeg, is this right?

select case true?
0

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

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

Author Commented:
thanx, that's great!

dj
0

## Featured Post

• 3
• 2
• 2
• +2
Tackle projects and never again get stuck behind a technical roadblock.