Select Case range 
Author Message
 Select Case range

Hello,

Is there a way in VBScript to have ranges of Case statements in a
Select...End Select loop? E.g. if I am evaluating values which can range
from 1 to 20, I'd like a neater way of doing the following:

Select Case intValue
    Case 1
        ' do something
    Case 2
        ' do something
    Case 3, 4, 5, 6, 7, 8, 9, 10
        ' do something
    Case 11, 12, 13, 14, 15, 16, 17, 18
        ' do something
    Case 19
        ' do something
    Case 20
        ' do something
End Select

Is there a way to replace the third and fourth Case statements with
something like

Case 3 To 10

or

Case Between 3 And 10

or

Case > 2 And Case < 11

Any assistance gratefully received

Best regards,

Mark Rae



Sat, 15 Feb 2003 03:00:00 GMT  
 Select Case range

Quote:

> Hello,

> Is there a way in VBScript to have ranges of Case statements in a
> Select...End Select loop? E.g. if I am evaluating values which can range
> from 1 to 20, I'd like a neater way of doing the following:

> Select Case intValue
>     Case 1
>         ' do something
>     Case 2
>         ' do something
>     Case 3, 4, 5, 6, 7, 8, 9, 10
>         ' do something
>     Case 11, 12, 13, 14, 15, 16, 17, 18
>         ' do something
>     Case 19
>         ' do something
>     Case 20
>         ' do something
> End Select

> Is there a way to replace the third and fourth Case statements with
> something like

> Case 3 To 10

> or

> Case Between 3 And 10

> or

> Case > 2 And Case < 11

> Any assistance gratefully received

> Best regards,

> Mark Rae

A quote from Michael Harris' response to a post titled "Select Case
statement in VBScript", dated Aug 11, 2000 ...

----------------
Not with the VB syntax - VBScript doesn't support it...

Select Case True

    Case (MyNumber >= 1 and  MyNumber <= 100)
        code.......
    Case (MyNumber >= 101 and  MyNumber <= 300)
        code.......
......
....... etc...

Michael Harris
MVP Scripting

---------------

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Sat, 15 Feb 2003 03:00:00 GMT  
 Select Case range
Thanks very much


Quote:

> > Hello,

> > Is there a way in VBScript to have ranges of Case statements in a
> > Select...End Select loop? E.g. if I am evaluating values which can range
> > from 1 to 20, I'd like a neater way of doing the following:

> > Select Case intValue
> >     Case 1
> >         ' do something
> >     Case 2
> >         ' do something
> >     Case 3, 4, 5, 6, 7, 8, 9, 10
> >         ' do something
> >     Case 11, 12, 13, 14, 15, 16, 17, 18
> >         ' do something
> >     Case 19
> >         ' do something
> >     Case 20
> >         ' do something
> > End Select

> > Is there a way to replace the third and fourth Case statements with
> > something like

> > Case 3 To 10

> > or

> > Case Between 3 And 10

> > or

> > Case > 2 And Case < 11

> > Any assistance gratefully received

> > Best regards,

> > Mark Rae

> A quote from Michael Harris' response to a post titled "Select Case
> statement in VBScript", dated Aug 11, 2000 ...

> ----------------
> Not with the VB syntax - VBScript doesn't support it...

> Select Case True

>     Case (MyNumber >= 1 and  MyNumber <= 100)
>         code.......
>     Case (MyNumber >= 101 and  MyNumber <= 300)
>         code.......
> ......
> ....... etc...

> Michael Harris
> MVP Scripting

> ---------------

> Tom Lavedas
> -----------
> http://www.pressroom.com/~tglbatch/



Sat, 15 Feb 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VBScript Select Case vs VB Select Case

2. "select...case", multiples cases not possible ?

3. Select Case and Case 0 To 9

4. How do I select a constant time range from a variable time range using VBA

5. .Range.Case constants

6. Case statement with a range of integers

7. selecting page ranges from a postscript file

8. read Image Attributes over selected Range

9. Need to Place Border in Cell or Selected Range of Excel

10. Selecting Range and then Setting the Borders collection

11. selecting a range of posts?

12. Help needed on Select Case

 

 
Powered by phpBB® Forum Software