Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2007
    Posts
    21

    Unanswered: select case problem

    case 1 to 10
    do this

    isnt it supposed to work?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Have you tried
    Code:
    Select Case someVariable
      Case 1 - 10
        Response.Write("1-10")
    
    Or...
    Select Case True
      Case (someVariable >= 1 AND someVariable <= 10)
        Response.Write("1-10")
    The "TO" keyword is not supported in VBScript.
    George
    Home | Blog

  3. #3
    Join Date
    Dec 2007
    Posts
    21
    ok,

    i'll try the first one later. unless it works i'll use an If, i think case True is not tidy.

    thx!! (again)

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I'm not sure the first suggestion will work, but I am sure that the second will.

    But you are right, with the second one you might as well use an If!

    The point in a case statement is that the case (i.e. someValue) is only evaluated the once and then compared to various conditions until true.
    An If statement evaluates the case for each executed line.

    So in theory, case statements are more efficient; the exception being Select True.
    George
    Home | Blog

  5. #5
    Join Date
    Dec 2007
    Posts
    21
    took me some time to remember adding End Ifs and Thens. am used to IF{}

    i keep seeing this _ line break for coding. ppl use it to break long lines in their code.... for some reason it isnt working for me...

    thats how i was trying to do it:

    record.source="SELECT * FROM cell1" _
    "cell2" _
    "cell3" _
    "cell4" _
    "WHERE etc etc etc"

    wt am i doing wrong? else than using SELECT *

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    1. You're using SELECT * (still!)
    2. Remember our string concatenator?
      You've split multiple strings over multiple lines
    George
    Home | Blog

  7. #7
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Wink little remark

    To : is supoted but not in the way written here (i.e. For i = 1 to 10)

    Does that SELECT CASE TRUE work ??? hmmm ok
    would rather do :
    Code:
    dim blValue as boolean=TRUE
    blValue=myTxt.Visible
    SELECT CASE blValue
    CASE TRUE
    CASE FALSE
    (as im writing it down seem logical that it would work.)
    but isn't the case allway true then ???
    True = true, why would u then have a select case

    SQL : Be sure to put a space befor you start a new line i.e.
    Code:
     
    slSql= "SELECT ID, Name,WHATEVER"  & _
                " , Age ,Sex" & _
                " , Street, No AS [House number]  ,Postalcode"& _
                " FROM MyTable" & _
                " INNER JOIN OTHER TABLE ON MyTable.ID=OTHER.ID" & _
                " WHERE ID < " & MyInputParameter & _
                " ORDER BY NAME"
    EDIT : ok,  Georgev was right as usual  ;-)  (was missing an quote and linecontinuation  )
    This way you never have to do a "difficult" left/right to see if there is a space at the end
    Break the line on each Function
    Last edited by Marvels; 02-13-08 at 11:01.
    Greetz Marvels -^.^-
    Developments : VB4 Through .Net; Basic; DOS ; CNC ; Sinclair
    Databases : SQL Server Through 2005; Access 3 Through 2003 ; Oracle 8 & 9.i ;
    OS : Win 3.11 Through XP ; NortonComander ; DOS

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Nice one Marvels


    Shame you made a mistake on that last little bit of code though :wink:
    George
    Home | Blog

Posting Permissions

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