Select Case Syntax Error

Discussion in 'ASP General' started by Kevin, Aug 27, 2004.

  1. Kevin

    Kevin Guest

    Hi, I am getting a syntax error
    Microsoft VBScript compilation error '800a03ea'

    Syntax error

    On the code below. The error references the "End Select" line

    Can anyone help me with what I am doing wrong?

    Thanks

    -========================================

    <%
    SELECT CASE iChoice

    Dim iChoice

    iChoice = varVendor

    Select Case iChoice
    Case "McGraw Hill"
    Response.Write "<!--#include
    virtual='/western/services/owdbMcGraw.asp'-->"
    Case "Alexander"
    Response.Write "<!--#include virtual='/western/services/owdbAlex.asp'-->"
    Case "Classical"
    Response.Write "<!--#include
    virtual='/western/services/owdbClassical.asp'-->"
    Case "CQPress"
    Response.Write "<!--#include
    virtual='/western/services/owdbCQPress.asp'-->"
    Case "FactsOnFile"
    Response.Write "<!--#include virtual='/western/services/owdbFOF.asp'-->"
    Case "Greenwood"
    Response.Write "<!--#include virtual='/western/services/owdbGreen.asp'-->"
    Case "Grove"
    Response.Write "<!--#include virtual='/western/services/owdbGrove.asp'-->"
    Case "Lexis-Nexis"
    Response.Write "<!--#include virtual='/western/services/owdbLexis.asp'-->"
    Case "Morningstar"
    Response.Write "<!--#include virtual='/western/services/owdbMStar.asp'-->"
    Case "Oxford Press"
    Response.Write "<!--#include
    virtual='/western/services/owdbOxford.asp'-->"
    Case "Vanderbilt"
    Response.Write "<!--#include virtual='/western/services/owdbVandy.asp'-->"
    Case "Westlaw"
    Response.Write "<!--#include
    virtual='/western/services/owdbWestlaw.asp'-->"
    Case "Wiley"
    Response.Write "<!--#include virtual='/western/services/owdbWiley.asp'-->"
    Case Else
    Response.Write "<h3>Please select a vendor. <br> <input type=button
    value=Back onClick='history.back(1);'></h3>"

    END SELECT

    %>
    Kevin, Aug 27, 2004
    #1
    1. Advertising

  2. Aaron [SQL Server MVP], Aug 27, 2004
    #2
    1. Advertising

  3. Kevin

    Steven Burn Guest

    Any reason you've got "Select Case iChoice" in there twice?

    --

    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!


    "Kevin" <thersitz @yahoo com> wrote in message
    news:...
    > Hi, I am getting a syntax error
    > Microsoft VBScript compilation error '800a03ea'
    >
    > Syntax error
    >
    > On the code below. The error references the "End Select" line
    >
    > Can anyone help me with what I am doing wrong?
    >
    > Thanks
    >
    > -========================================
    >
    > <%
    > SELECT CASE iChoice
    >
    > Dim iChoice
    >
    > iChoice = varVendor
    >
    > Select Case iChoice
    > Case "McGraw Hill"
    > Response.Write "<!--#include
    > virtual='/western/services/owdbMcGraw.asp'-->"
    > Case "Alexander"
    > Response.Write "<!--#include

    virtual='/western/services/owdbAlex.asp'-->"
    > Case "Classical"
    > Response.Write "<!--#include
    > virtual='/western/services/owdbClassical.asp'-->"
    > Case "CQPress"
    > Response.Write "<!--#include
    > virtual='/western/services/owdbCQPress.asp'-->"
    > Case "FactsOnFile"
    > Response.Write "<!--#include virtual='/western/services/owdbFOF.asp'-->"
    > Case "Greenwood"
    > Response.Write "<!--#include

    virtual='/western/services/owdbGreen.asp'-->"
    > Case "Grove"
    > Response.Write "<!--#include

    virtual='/western/services/owdbGrove.asp'-->"
    > Case "Lexis-Nexis"
    > Response.Write "<!--#include

    virtual='/western/services/owdbLexis.asp'-->"
    > Case "Morningstar"
    > Response.Write "<!--#include

    virtual='/western/services/owdbMStar.asp'-->"
    > Case "Oxford Press"
    > Response.Write "<!--#include
    > virtual='/western/services/owdbOxford.asp'-->"
    > Case "Vanderbilt"
    > Response.Write "<!--#include

    virtual='/western/services/owdbVandy.asp'-->"
    > Case "Westlaw"
    > Response.Write "<!--#include
    > virtual='/western/services/owdbWestlaw.asp'-->"
    > Case "Wiley"
    > Response.Write "<!--#include

    virtual='/western/services/owdbWiley.asp'-->"
    > Case Else
    > Response.Write "<h3>Please select a vendor. <br> <input type=button
    > value=Back onClick='history.back(1);'></h3>"
    >
    > END SELECT
    >
    > %>
    >
    >
    Steven Burn, Aug 27, 2004
    #3
  4. Kevin

    Kevin Guest

    Thanks Aaron. My original working code was:

    <%
    If varVendor = "McGraw Hill" Then
    %>
    <!--#include virtual="/western/services/owdbMcGraw.asp"-->
    <%
    ElseIf varVendor = "Classical" Then
    %>
    <!--#include virtual="/western/services/owdbClassical.asp"-->
    <%
    ElseIf varVendor = "Lexis-Nexis" Then
    %>
    <!--#include virtual="/western/services/owdbLexis.asp"-->
    <%
    ElseIf varVendor = "Oxford Press" Then
    %>
    <!--#include virtual="/western/services/owdbOxford.asp"-->

    and on and on -- etc.

    But my string of If Then ElsIf statements is up to 15 and so I was trying to
    do the select case to reduce the statements. Guess I am back to the If Then
    ....ElseIf

    I am sure I read that faq way back when and that is how I came to my
    original If Then syntax.

    Thanks


    "Aaron [SQL Server MVP]" <> wrote in message
    news:...
    > > Case "McGraw Hill"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbMcGraw.asp'-->"

    >
    > You can't do this. Look at server.execute or see

    http://www.aspfaq.com/2042
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
    Kevin, Aug 27, 2004
    #4
  5. Kevin

    Kevin Guest

    Thanks Curt. I made the correction and now it executes, but the result is
    what Aaron was alluding to. So I guess I am returning to the If ... Then ...
    Else code.


    "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
    news:...
    > you have Select Case twice
    >
    > --
    > Curt Christianson
    > Owner/Lead Developer, DF-Software
    > Site: http://www.Darkfalz.com
    > Blog: http://blog.Darkfalz.com
    >
    >
    > "Kevin" <thersitz @yahoo com> wrote in message
    > news:...
    > > Hi, I am getting a syntax error
    > > Microsoft VBScript compilation error '800a03ea'
    > >
    > > Syntax error
    > >
    > > On the code below. The error references the "End Select" line
    > >
    > > Can anyone help me with what I am doing wrong?
    > >
    > > Thanks
    > >
    > > -========================================
    > >
    > > <%
    > > SELECT CASE iChoice
    > >
    > > Dim iChoice
    > >
    > > iChoice = varVendor
    > >
    > > Select Case iChoice
    > > Case "McGraw Hill"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbMcGraw.asp'-->"
    > > Case "Alexander"
    > > Response.Write "<!--#include

    virtual='/western/services/owdbAlex.asp'-->"
    > > Case "Classical"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbClassical.asp'-->"
    > > Case "CQPress"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbCQPress.asp'-->"
    > > Case "FactsOnFile"
    > > Response.Write "<!--#include

    virtual='/western/services/owdbFOF.asp'-->"
    > > Case "Greenwood"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbGreen.asp'-->"
    > > Case "Grove"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbGrove.asp'-->"
    > > Case "Lexis-Nexis"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbLexis.asp'-->"
    > > Case "Morningstar"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbMStar.asp'-->"
    > > Case "Oxford Press"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbOxford.asp'-->"
    > > Case "Vanderbilt"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbVandy.asp'-->"
    > > Case "Westlaw"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbWestlaw.asp'-->"
    > > Case "Wiley"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbWiley.asp'-->"
    > > Case Else
    > > Response.Write "<h3>Please select a vendor. <br> <input type=button
    > > value=Back onClick='history.back(1);'></h3>"
    > >
    > > END SELECT
    > >
    > > %>
    > >
    > >

    >
    >
    Kevin, Aug 27, 2004
    #5
  6. Kevin

    Kevin Guest

    yeah, operator error. Curt busted me on that as well. Still a little fuzzy
    on Select Case. Thanks for your time.

    Kevin

    "Steven Burn" <> wrote in message
    news:%...
    > Any reason you've got "Select Case iChoice" in there twice?
    >
    > --
    >
    > Regards
    >
    > Steven Burn
    > Ur I.T. Mate Group
    > www.it-mate.co.uk
    >
    > Keeping it FREE!
    >
    >
    > "Kevin" <thersitz @yahoo com> wrote in message
    > news:...
    > > Hi, I am getting a syntax error
    > > Microsoft VBScript compilation error '800a03ea'
    > >
    > > Syntax error
    > >
    > > On the code below. The error references the "End Select" line
    > >
    > > Can anyone help me with what I am doing wrong?
    > >
    > > Thanks
    > >
    > > -========================================
    > >
    > > <%
    > > SELECT CASE iChoice
    > >
    > > Dim iChoice
    > >
    > > iChoice = varVendor
    > >
    > > Select Case iChoice
    > > Case "McGraw Hill"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbMcGraw.asp'-->"
    > > Case "Alexander"
    > > Response.Write "<!--#include

    > virtual='/western/services/owdbAlex.asp'-->"
    > > Case "Classical"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbClassical.asp'-->"
    > > Case "CQPress"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbCQPress.asp'-->"
    > > Case "FactsOnFile"
    > > Response.Write "<!--#include

    virtual='/western/services/owdbFOF.asp'-->"
    > > Case "Greenwood"
    > > Response.Write "<!--#include

    > virtual='/western/services/owdbGreen.asp'-->"
    > > Case "Grove"
    > > Response.Write "<!--#include

    > virtual='/western/services/owdbGrove.asp'-->"
    > > Case "Lexis-Nexis"
    > > Response.Write "<!--#include

    > virtual='/western/services/owdbLexis.asp'-->"
    > > Case "Morningstar"
    > > Response.Write "<!--#include

    > virtual='/western/services/owdbMStar.asp'-->"
    > > Case "Oxford Press"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbOxford.asp'-->"
    > > Case "Vanderbilt"
    > > Response.Write "<!--#include

    > virtual='/western/services/owdbVandy.asp'-->"
    > > Case "Westlaw"
    > > Response.Write "<!--#include
    > > virtual='/western/services/owdbWestlaw.asp'-->"
    > > Case "Wiley"
    > > Response.Write "<!--#include

    > virtual='/western/services/owdbWiley.asp'-->"
    > > Case Else
    > > Response.Write "<h3>Please select a vendor. <br> <input type=button
    > > value=Back onClick='history.back(1);'></h3>"
    > >
    > > END SELECT
    > >
    > > %>
    > >
    > >

    >
    >
    Kevin, Aug 27, 2004
    #6
  7. Well, you could do this, but it is tedious and unmanageable, IMHO:

    <%
    SELECT CASE varVendor
    CASE "McGraw Hill"
    %>
    <!--#include virtual=/western/services/owdbMcgraw.asp-->
    <%
    CASE "Classical"
    %>
    <!--#include virtual=/western/services/owdbClassical.asp-->
    <%
    ...

    Or better still, create an array or dictionary object that allows you to
    match "McGraw-Hill" -> "owdbMcgraw.asp", then you could say this instead of
    having 15 conditionals:

    Set d = CreateObject("Scripting.Dictionary")
    d.Add "McGraw Hill", "owdbMcgraw.asp"
    d.Add "Classical", "osdbClassical.asp"
    ' ... add others here or populate from DB ...
    Server.Execute d.item(varVendor)

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "Kevin" <thersitz @yahoo com> wrote in message
    news:...
    > Thanks Aaron. My original working code was:
    >
    > <%
    > If varVendor = "McGraw Hill" Then
    > %>
    > <!--#include virtual="/western/services/owdbMcGraw.asp"-->
    > <%
    > ElseIf varVendor = "Classical" Then
    > %>
    > <!--#include virtual="/western/services/owdbClassical.asp"-->
    > <%
    > ElseIf varVendor = "Lexis-Nexis" Then
    > %>
    > <!--#include virtual="/western/services/owdbLexis.asp"-->
    > <%
    > ElseIf varVendor = "Oxford Press" Then
    > %>
    > <!--#include virtual="/western/services/owdbOxford.asp"-->
    >
    > and on and on -- etc.
    >
    > But my string of If Then ElsIf statements is up to 15 and so I was trying

    to
    > do the select case to reduce the statements. Guess I am back to the If

    Then
    > ...ElseIf
    >
    > I am sure I read that faq way back when and that is how I came to my
    > original If Then syntax.
    >
    > Thanks
    >
    >
    > "Aaron [SQL Server MVP]" <> wrote in message
    > news:...
    > > > Case "McGraw Hill"
    > > > Response.Write "<!--#include
    > > > virtual='/western/services/owdbMcGraw.asp'-->"

    > >
    > > You can't do this. Look at server.execute or see

    > http://www.aspfaq.com/2042
    > >
    > > --
    > > http://www.aspfaq.com/
    > > (Reverse address to reply.)
    > >
    > >

    >
    >
    Aaron [SQL Server MVP], Aug 27, 2004
    #7
  8. Kevin

    Bob Lehmann Guest

    The difference is the context switching in you If...ElseIf....

    It's still icky, but you could do the same thing with Select Case...
    <%
    Select Case iChoice
    Case "McGraw Hill"
    %>
    <!--#include virtual='/western/services/owdbMcGraw.asp'-->
    <%
    Case "Classical"
    %>
    <!--#include virtual="/western/services/owdbClassical.asp"-->
    <%
    End Select
    %>

    Bob Lehmann

    "Kevin" <thersitz @yahoo com> wrote in message
    news:...
    > Thanks Aaron. My original working code was:
    >
    > <%
    > If varVendor = "McGraw Hill" Then
    > %>
    > <!--#include virtual="/western/services/owdbMcGraw.asp"-->
    > <%
    > ElseIf varVendor = "Classical" Then
    > %>
    > <!--#include virtual="/western/services/owdbClassical.asp"-->
    > <%
    > ElseIf varVendor = "Lexis-Nexis" Then
    > %>
    > <!--#include virtual="/western/services/owdbLexis.asp"-->
    > <%
    > ElseIf varVendor = "Oxford Press" Then
    > %>
    > <!--#include virtual="/western/services/owdbOxford.asp"-->
    >
    > and on and on -- etc.
    >
    > But my string of If Then ElsIf statements is up to 15 and so I was trying

    to
    > do the select case to reduce the statements. Guess I am back to the If

    Then
    > ...ElseIf
    >
    > I am sure I read that faq way back when and that is how I came to my
    > original If Then syntax.
    >
    > Thanks
    >
    >
    > "Aaron [SQL Server MVP]" <> wrote in message
    > news:...
    > > > Case "McGraw Hill"
    > > > Response.Write "<!--#include
    > > > virtual='/western/services/owdbMcGraw.asp'-->"

    > >
    > > You can't do this. Look at server.execute or see

    > http://www.aspfaq.com/2042
    > >
    > > --
    > > http://www.aspfaq.com/
    > > (Reverse address to reply.)
    > >
    > >

    >
    >
    Bob Lehmann, Aug 27, 2004
    #8
  9. Kevin

    Harag Guest

    On Fri, 27 Aug 2004 14:22:48 -0700, "Kevin" <thersitz @yahoo com>
    wrote:

    >Thanks Aaron. My original working code was:
    >
    ><%
    > If varVendor = "McGraw Hill" Then
    >%>
    ><!--#include virtual="/western/services/owdbMcGraw.asp"-->
    ><%
    > ElseIf varVendor = "Classical" Then
    >%>
    ><!--#include virtual="/western/services/owdbClassical.asp"-->
    ><%
    > ElseIf varVendor = "Lexis-Nexis" Then
    >%>
    ><!--#include virtual="/western/services/owdbLexis.asp"-->
    ><%
    > ElseIf varVendor = "Oxford Press" Then
    >%>
    ><!--#include virtual="/western/services/owdbOxford.asp"-->
    >
    >and on and on -- etc.



    Why not make it even easier to read & maintain. Put all the code in
    your includes into several functions/Subs, eg:

    <!--#include virtual="/western/services/owdbMcGraw.asp"-->
    would contain

    function DisplayMcGraw()
    .....
    end function

    <!--#include virtual="/western/services/owdbClassical.asp"-->
    contains:
    function DisplayClassical()
    .....
    end function


    or
    <!--#include virtual="/western/services/owdbALL.asp"-->
    would contain all the functions required in the owdb services.

    Then include the file(s) at the very top of the page then in your
    select case as:

    SELECT CASE varVendor
    CASE "McGraw Hill"
    DisplayMcGraw()
    CASE "Classical"
    DisplayClasical()
    ....
    .....
    END SELECT


    IMHO it looks more understanding and more maintainable. and your not
    constantly swiching between asp & html code with <%.. %>


    HTH

    Al.

    >
    >But my string of If Then ElsIf statements is up to 15 and so I was trying to
    >do the select case to reduce the statements. Guess I am back to the If Then
    >...ElseIf
    >
    >I am sure I read that faq way back when and that is how I came to my
    >original If Then syntax.
    >
    >Thanks
    >
    >
    >"Aaron [SQL Server MVP]" <> wrote in message
    >news:...
    >> > Case "McGraw Hill"
    >> > Response.Write "<!--#include
    >> > virtual='/western/services/owdbMcGraw.asp'-->"

    >>
    >> You can't do this. Look at server.execute or see

    >http://www.aspfaq.com/2042
    >>
    >> --
    >> http://www.aspfaq.com/
    >> (Reverse address to reply.)
    >>
    >>

    >
    Harag, Aug 28, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tee
    Replies:
    3
    Views:
    7,802
    Herfried K. Wagner [MVP]
    Jun 23, 2004
  2. Lakshmi Narayanan.R

    "Case 1 To 5" in Select case, giving Error!!. Why?

    Lakshmi Narayanan.R, Mar 2, 2005, in forum: ASP General
    Replies:
    10
    Views:
    348
    Bob Barrows [MVP]
    Mar 4, 2005
  3. Penny
    Replies:
    8
    Views:
    109
    Roland Hall
    May 13, 2005
  4. aa
    Replies:
    14
    Views:
    321
  5. palmiere
    Replies:
    1
    Views:
    396
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page