Select Case and Case 0 To 9 
Author Message
 Select Case and Case 0 To 9

Can anyone confirm if VBScript Select Case supports the N To N statement as below?

I seem to be getting Syntax Error on the:

Case 0 to 9

but can't find a conclusive yes or no on the support for the Case statement at the moment in Google.

The value as read from a session variable is a string "7" but I'm pretty sure it should coerce it to a numeric. Even so,
adding the explicit:

    plngCallID = CLng(plngCallID)

hasn't helped a jot.

Select Case plngCallID
Case 0 To 9
    pstrRedirect = "requirements\browser_check.asp"
Case 10 To 19
    pstrRedirect = "service\arcims_init.asp"
Case 20 To 29
    'Get a simple map image.
    pstrRedirect = "service\arcims_image_request.asp"
Case Else
    plngCallID = 0
    pstrReturnValue = vbNullString
End Select

Cheers,

Chris.



Fri, 28 Oct 2005 20:55:45 GMT  
 Select Case and Case 0 To 9
The full Select Case syntax of VB is supported in script,
but it can be made to approximate it as follows (thanks to
Michael Harris):

Select Case True

  Case (plngCallID=>0) and (plngCallID<=9)

  Case (plngCallID=>10) and (plngCallID<=19)
...

Or, if you can live with the fact that the order of the
CASE conditions can be used in place of the lower bound,
it can be simplified a bit ...

Select Case True

  Case (plngCallID=>0) and (plngCallID<=9)

  Case plngCallID<=19

  Case plngCallID<=29
...

Tom Lavedas
===========

Quote:
>-----Original Message-----
>Can anyone confirm if VBScript Select Case supports the N

To N statement as below?
Quote:

>I seem to be getting Syntax Error on the:

>Case 0 to 9

>but can't find a conclusive yes or no on the support for

the Case statement at the moment in Google.
Quote:

>The value as read from a session variable is a string "7"

but I'm pretty sure it should coerce it to a numeric. Even
so,
Quote:
>adding the explicit:

>    plngCallID = CLng(plngCallID)

>hasn't helped a jot.

>Select Case plngCallID
>Case 0 To 9
>    pstrRedirect = "requirements\browser_check.asp"
>Case 10 To 19
>    pstrRedirect = "service\arcims_init.asp"
>Case 20 To 29
>    'Get a simple map image.
>    pstrRedirect = "service\arcims_image_request.asp"
>Case Else
>    plngCallID = 0
>    pstrReturnValue = vbNullString
>End Select

>Cheers,

>Chris.



Fri, 28 Oct 2005 21:12:05 GMT  
 Select Case and Case 0 To 9
Confirmed

You could do something like this if you like.

Select Case True
Case plngCallID < 10
    response.write "0-9"
Case plngCallID < 20
    response.write "10-19"
Case plngCallID < 30
    response.write "20-29"
Case Else
    response.write "Else"
End Select

Or if you want to be more exact, you can do plngCallID >=0 And plngCallID <
10 or whatever.

Or, you could do "Case 0,1,2,3,4,5,6,7,8,9", "Case
10,11,12,13,14,15,16,17,18,19" ...

Ray at work


Quote:
> Can anyone confirm if VBScript Select Case supports the N To N statement
as below?

> I seem to be getting Syntax Error on the:

> Case 0 to 9

> but can't find a conclusive yes or no on the support for the Case

statement at the moment in Google.
Quote:

> The value as read from a session variable is a string "7" but I'm pretty

sure it should coerce it to a numeric. Even so,
Quote:
> adding the explicit:

>     plngCallID = CLng(plngCallID)

> hasn't helped a jot.

> Select Case plngCallID
> Case 0 To 9
>     pstrRedirect = "requirements\browser_check.asp"
> Case 10 To 19
>     pstrRedirect = "service\arcims_init.asp"
> Case 20 To 29
>     'Get a simple map image.
>     pstrRedirect = "service\arcims_image_request.asp"
> Case Else
>     plngCallID = 0
>     pstrReturnValue = vbNullString
> End Select

> Cheers,

> Chris.



Fri, 28 Oct 2005 21:12:05 GMT  
 Select Case and Case 0 To 9
Yep - I suspected and have a number of workarounds to test (along the lines you suggested).

Thanks for the confirmation.

Chris.

The full Select Case syntax of VB is supported in script,
but it can be made to approximate it as follows (thanks to
Michael Harris):

Select Case True

  Case (plngCallID=>0) and (plngCallID<=9)

  Case (plngCallID=>10) and (plngCallID<=19)
...

Or, if you can live with the fact that the order of the
CASE conditions can be used in place of the lower bound,
it can be simplified a bit ...

Select Case True

  Case (plngCallID=>0) and (plngCallID<=9)

  Case plngCallID<=19

  Case plngCallID<=29
...

Tom Lavedas
===========

Quote:
>-----Original Message-----
>Can anyone confirm if VBScript Select Case supports the N

To N statement as below?
Quote:

>I seem to be getting Syntax Error on the:

>Case 0 to 9

>but can't find a conclusive yes or no on the support for

the Case statement at the moment in Google.
Quote:

>The value as read from a session variable is a string "7"

but I'm pretty sure it should coerce it to a numeric. Even
so,
Quote:
>adding the explicit:

>    plngCallID = CLng(plngCallID)

>hasn't helped a jot.

>Select Case plngCallID
>Case 0 To 9
>    pstrRedirect = "requirements\browser_check.asp"
>Case 10 To 19
>    pstrRedirect = "service\arcims_init.asp"
>Case 20 To 29
>    'Get a simple map image.
>    pstrRedirect = "service\arcims_image_request.asp"
>Case Else
>    plngCallID = 0
>    pstrReturnValue = vbNullString
>End Select

>Cheers,

>Chris.



Fri, 28 Oct 2005 21:45:14 GMT  
 Select Case and Case 0 To 9
Hmm.
I tried the first one but got nowhere [Syntax Error] although yours has a space between the < and the number. I'll try
it again.
I also tried the second one but my fingers got tired at about 13 or so and I gave up.

Thanks.

Chris.


Confirmed

You could do something like this if you like.

Select Case True
Case plngCallID < 10
    response.write "0-9"
Case plngCallID < 20
    response.write "10-19"
Case plngCallID < 30
    response.write "20-29"
Case Else
    response.write "Else"
End Select

Or if you want to be more exact, you can do plngCallID >=0 And plngCallID <
10 or whatever.

Or, you could do "Case 0,1,2,3,4,5,6,7,8,9", "Case
10,11,12,13,14,15,16,17,18,19" ...

Ray at work


Quote:
> Can anyone confirm if VBScript Select Case supports the N To N statement
as below?

> I seem to be getting Syntax Error on the:

> Case 0 to 9

> but can't find a conclusive yes or no on the support for the Case

statement at the moment in Google.
Quote:

> The value as read from a session variable is a string "7" but I'm pretty

sure it should coerce it to a numeric. Even so,
Quote:
> adding the explicit:

>     plngCallID = CLng(plngCallID)

> hasn't helped a jot.

> Select Case plngCallID
> Case 0 To 9
>     pstrRedirect = "requirements\browser_check.asp"
> Case 10 To 19
>     pstrRedirect = "service\arcims_init.asp"
> Case 20 To 29
>     'Get a simple map image.
>     pstrRedirect = "service\arcims_image_request.asp"
> Case Else
>     plngCallID = 0
>     pstrReturnValue = vbNullString
> End Select

> Cheers,

> Chris.



Fri, 28 Oct 2005 21:44:21 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VBScript Select Case vs VB Select Case

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

3. Converting a Upper Case String to Upper and Lower Case

4. Switch/Case with multiple tests in case

5. Change Case (Upper/Lower/Setence/Title CASE)

6. RTF format - changing case (and case only!)

7. Convert from upper case to mixed case

8. ISO: SQL or CR method for converting upper case text to proper case

9. Change lower case to upper case

10. Help needed on Select Case

11. SELECT CASE problem

12. Select case not working

 

 
Powered by phpBB® Forum Software