Comparing Integer Values

1. Senior Member
Join Date
Dec 1969
Posts
121

Comparing Integer Values

Hello,<BR><BR>Hopefully somebody can help (its pretty easy, just got a blank mind).<BR><BR>I have set up a "SELECT CASE" statement to set a variable called "message" depending on your score, but I need to know how to code "Where percentage is between 26 and 50", I have tried:<BR><BR>SELECT CASE Percentage<BR><BR> CASE Percentage &#060;= 25<BR> Message="Under 25% DOE!"<BR><BR> CASE Percentage &#062;= 26 AND &#060;= 50<BR> Message="Between 26 and 50%"<BR><BR> CASE Percentage &#062;= 51 AND &#060;= 75<BR> Message="Between 51 and 75%"<BR><BR> CASE Percentage &#062;= 76<BR> Message="Over 75% WOW!"<BR><BR>END SELECT<BR><BR>Any help would be great.<BR><BR>Thanks<BR><BR>JiMi

2. Senior Member
Join Date
Dec 1969
Posts
5,955

I suggest you use If statements...

...instead. As far as I know, the Select statement doesn&#039;t allow to specify a range - see http://msdn.microsoft.com/library/en-us/script56/html/vsstmSelectCase.asp for more information.<BR><BR>But you could do:<BR><BR>If Percentage &#060;= 25<BR>&nbsp;&nbsp;&nbsp;Message = "Under 25% DOE!"<BR>Else If Percentage &#062;= 26 And Percentage &#060;= 50<BR>&nbsp;&nbsp;&nbsp;Message = "Between 26 and 50%"<BR>...<BR>End If<BR><BR>Oliver.

3. Senior Member
Join Date
Dec 1969
Posts
5,955

Sorry, there shouldn't be a space...

...in ElseIf. Too quick off the mark.<BR><BR>Oliver.

4. Senior Member
Join Date
Dec 1969
Posts
121

RE: I suggest you use If statements...

Thanks, i&#039;ll give it a go.<BR><BR>JiMi

5. Senior Member
Join Date
Dec 1969
Posts
16,931

RE: Comparing Integer Values

Have you looked up in the VBScript reference if it&#039;s possible to do this using VBScript&#039;s "select case" statement?<BR><BR>If all you&#039;re doing is checking quarters, why not use MOD 25 to get a number between 0 and 4, then you can easily write a select case statement, can&#039;t you?<BR><BR>Craig.,

6. Senior Member
Join Date
Dec 1969
Posts
121

RE: I suggest you use If statements...

You missed out the "THEN"&#039;s but it worked apart from that.<BR><BR>Cheers<BR><BR>JiMi

7. Senior Member
Join Date
Dec 1969
Posts
5,955

Bugger, that shows you...

...how rusty I am in VBScript. I&#039;m using JScript all the time now. :-/<BR><BR>Sorry about the incorrect syntax, but you got there in the end. :-)<BR><BR>Oliver.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•