Select Case Between Value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J-P-W

    Select Case Between Value

    "Stock Value" Could be anything from 0 to a million or so, and might
    include a decimal (12345.67)

    I can't find how to do this:

    Select Case StockValue
    Case 0 To 30000
    response.Write( "Less than 30000")
    Case 30000 To 80000
    response.Write( "30000 to 80000")
    Case 80000 To 180000
    response.Write( "80000 to 180000")
    Case Else ' > 180000
    response.Write( "Greater than 180000")
    End Select

    I also tried Case > 0 And <30000 .... and so on

    Can anyone advise how to write this select script please?

    Thank you

    Jon

  • Steven Burn

    #2
    Re: Select Case Between Value

    StockValue = 1000
    Select Case True
    Case StockValue <= 30000: response.Write "StockValue [" & StockValue & "]
    IS Less than 30000<br><br>"
    Case StockValue <= 80000: response.Write "StockValue [" & StockValue & "]
    IS 30000 to 80000<br><br>"
    Case StockValue <= 180000: response.Write "StockValue [" & StockValue & "]
    IS 80000 to 180000<br><br>"
    Case Else: response.Write "StockValue [" & StockValue & "] IS Greater than
    180000<br><br>"
    End Select



    --
    Regards

    Steven Burn
    Ur I.T. Mate Group


    Keeping it FREE!

    "J-P-W" <jonpwebb@gmail .com> wrote in message
    news:1149589376 .346759.190430@ y43g2000cwc.goo glegroups.com.. .[color=blue]
    > "Stock Value" Could be anything from 0 to a million or so, and might
    > include a decimal (12345.67)
    >
    > I can't find how to do this:
    >
    > Select Case StockValue
    > Case 0 To 30000
    > response.Write( "Less than 30000")
    > Case 30000 To 80000
    > response.Write( "30000 to 80000")
    > Case 80000 To 180000
    > response.Write( "80000 to 180000")
    > Case Else ' > 180000
    > response.Write( "Greater than 180000")
    > End Select
    >
    > I also tried Case > 0 And <30000 .... and so on
    >
    > Can anyone advise how to write this select script please?
    >
    > Thank you
    >
    > Jon
    >[/color]


    Comment

    • J-P-W

      #3
      Re: Select Case Between Value

      Thanks Steve, I guess the Select Case _True_ was what I need to read up
      on! Regards
      Steven Burn wrote:[color=blue]
      > StockValue = 1000
      > Select Case True
      > Case StockValue <= 30000: response.Write "StockValue [" & StockValue & "]
      > IS Less than 30000<br><br>"
      > Case StockValue <= 80000: response.Write "StockValue [" & StockValue & "]
      > IS 30000 to 80000<br><br>"
      > Case StockValue <= 180000: response.Write "StockValue [" & StockValue & "]
      > IS 80000 to 180000<br><br>"
      > Case Else: response.Write "StockValue [" & StockValue & "] IS Greater than
      > 180000<br><br>"
      > End Select
      >
      > http://mysteryfcm.co.uk/misc/sc_stockvalue.asp
      >
      > --
      > Regards
      >
      > Steven Burn
      > Ur I.T. Mate Group
      > www.it-mate.co.uk
      >
      > Keeping it FREE!
      >
      > "J-P-W" <jonpwebb@gmail .com> wrote in message
      > news:1149589376 .346759.190430@ y43g2000cwc.goo glegroups.com.. .[color=green]
      > > "Stock Value" Could be anything from 0 to a million or so, and might
      > > include a decimal (12345.67)
      > >
      > > I can't find how to do this:
      > >
      > > Select Case StockValue
      > > Case 0 To 30000
      > > response.Write( "Less than 30000")
      > > Case 30000 To 80000
      > > response.Write( "30000 to 80000")
      > > Case 80000 To 180000
      > > response.Write( "80000 to 180000")
      > > Case Else ' > 180000
      > > response.Write( "Greater than 180000")
      > > End Select
      > >
      > > I also tried Case > 0 And <30000 .... and so on
      > >
      > > Can anyone advise how to write this select script please?
      > >
      > > Thank you
      > >
      > > Jon
      > >[/color][/color]

      Comment

      • Bob Barrows [MVP]

        #4
        Re: Select Case Between Value

        J-P-W wrote:[color=blue]
        > "Stock Value" Could be anything from 0 to a million or so, and might
        > include a decimal (12345.67)
        >
        > I can't find how to do this:
        >
        > Select Case StockValue
        > Case 0 To 30000
        > response.Write( "Less than 30000")[/color]

        Atually, the To comparison would include 30000, so a value of 30000 would
        make this true.
        [color=blue]
        > Case 30000 To 80000
        > response.Write( "30000 to 80000")
        > Case 80000 To 180000
        > response.Write( "80000 to 180000")
        > Case Else ' > 180000
        > response.Write( "Greater than 180000")
        > End Select
        >
        > I also tried Case > 0 And <30000 .... and so on
        >
        > Can anyone advise how to write this select script please?
        >
        > Thank you
        >
        > Jon[/color]

        In VB, what you've done would work. Unfortunately, this is not one of the
        pieces of "syntactic sugar" that survived during the creation of vbscript.
        However, there is a workaround:

        Select Case True
        Case (StockValue<300 00)
        Case (StockValue>=30 000 and StockValue<8000 0)
        etc.
        End Select


        You can also use
        If ... then
        ElseIf ... then
        Else
        End If

        Bob Barrows
        PS. you can download the vbscript documentation from here:

        --
        Microsoft MVP - ASP/ASP.NET
        Please reply to the newsgroup. This email account is my spam trap so I
        don't check it very often. If you must reply off-line, then remove the
        "NO SPAM"


        Comment

        Working...