SELECT CASE in ASP???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bã§TãRÐ

    #16
    Re: What the H_ _ _ am I doing wrong????

    case info is usually sent vit the url in a querystring or in a hidden form variable. I'll do the querystring example for you but the hidden form field is just as easy.
    the Url you are passing http://www.somedomain.com?lan=English

    select case request.queryst ring("lan")

    case "English"
    do something here
    case "French"
    do something here
    case else
    do something here
    end select

    thats pretty much it - the case else statement is a default if nothing else is chosen

    Hope that helps
    - Bastard



    On Sat, 7 Aug 2004 17:21:54 -0400, "Brad" <info@webdevcre ations.com> wrote:
    [color=blue]
    >This entire thing is rather embarrassing as I cannto get it to work.
    >
    >I have 2 input strings that will contain URL's (the contents of the textbox
    >strings is a non-issue.
    >
    >I have to allow the user to be able to enter into JUST the English OR Just
    >the FRENCH or be able to Enter into BOTH ENGLISH and FRENCH
    >
    >I was using an IF ELSE statement but was having a hard time with it, as the
    >scenerio's conflicted.
    >
    >Example:
    >
    >If strEnglish<>emp ty AND strFrench <>empty Then 'Both have something inside
    >them
    >'ENTER BOTH INTO DB
    >End If
    >
    >If strEnglish<>emp ty Then 'Just English has something
    >inside it
    >'ENTER JUST THE ENGLISH
    >End If
    >
    >If strFrench<>empt y Then 'Just French has something
    >inside it
    >'ENTER JUST THE FRENCH
    >End If
    >
    >
    >Now for BOTH of the string textbox inputs , it worked well, but if I just
    >entered on either ENGLISH or FRENCH, well it would not acknowledge it......
    >
    >So I think that maybe I should be using a CASE SELECT..but now I have no
    >idea how to make that work for my code, especially in ASP.
    >
    >SAD yet true...but willing to learn how to make it work..........b ut have
    >yet to find an example that will make me understand..per haps I am making it
    >harder than it is...a usual problem of mine.;))
    >
    >Can someone help me out here, as I am having a hard time to get this to
    >work.
    >
    >Thanks in advance,
    >
    >~Brad (NEWBIE to ASP CASE Selects)
    >
    >"Newbie" <Newbie@helpme. com> wrote in message
    >news:Y0bRc.504 93$Vm1.1312419@ news20.bellglob al.com...[color=green]
    >> Dear friends,
    >>
    >> I am having a hard time understanding how to use a SELECT CASE in ASP. I
    >> have used it in VB but never in ASP scripting.
    >>
    >> Scenerio:
    >>
    >> I have 2 textboxes on a form that I have to allow entry to one or the[/color]
    >other[color=green]
    >> or Both at the same time. Now I tried to use an If ElseIf but it got too
    >> hard to track, so now I am using a SELECT CASE Statement.
    >>
    >> TEXBOX1 named strEnglish
    >> TEXBOX2 named strFrench
    >>
    >> My code:
    >> <%
    >> strEnglish=Requ est.Form("strEn glish")
    >> strFrench=Reque st.Form("strFre nch")
    >>
    >> Select Case
    >>
    >> Then I have no idea how to go from here, because I have 2 input textboxes[/color]
    >to[color=green]
    >> follow.
    >>
    >>
    >> I found this example but I do not know how to apply it to my situation as[/color]
    >I[color=green]
    >> have to folow 2 textbox entries.
    >>
    >> <%
    >> UserName=reques t.form("UserNam e")
    >> Select Case UserName
    >> Case "Kathi"
    >> Msg = "You deserve a break. Take the day off!"
    >> Case "JD","Anne"
    >> Msg = "Don't forget to call Kathi today!"
    >> Case Else
    >> Msg = "Do I know you?"
    >> End Select
    >> response.write Msg
    >> %>
    >>
    >> Can someone please help me out, a known tutorial, perhaps an example or[/color]
    >just[color=green]
    >> plain good ole help please??
    >>
    >> Thanks in advance,
    >>
    >> ~Newbie
    >>
    >>[/color]
    >[/color]

    Comment

    • Brad

      #17
      Re:THANKS TO ALL ~ PROBLEM SOLVED!! ;))

      After running m Debug code, I found that my problem was not within my SELECT
      CASE. I was passing many varaibles and one of the varaibles, I changed the
      name of it (as the IE: intNewID, where this would come after an INSERT to my
      DB, returned from my Stored Procedure as an OUTPUT param.

      The bottom line, the SELECT CASE or IF ELSEIF..... Both worked properlly, as
      soon as I ran through using Response.Write ... Reponse.Flush, I found that
      I was not making my intNewID available to the page, thus the reason why I
      could not get the second FORM page to display itself.

      Well all is well now,

      Thanks to everyone for their input,

      ~Brad
      ;)

      "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
      news:uc1ZayafEH A.3632@TK2MSFTN GP11.phx.gbl...[color=blue]
      > I don't have enough information. I have no idea what "works great" and
      > "doesn't work" mean. I have no idea what code is running in each branch of
      > the select case statement.
      >
      > It sounds as if you need to do some debugging to find out what your
      > variables contain at each step of the operation. Use alert() in your
      > cliinet-side code and response.write in your server-side code to figure
      > outwhat's going on.
      >
      > Bob Barrows
      >
      > Brad wrote:[color=green]
      > > Good evening Bob,
      > >
      > > Now using the SELECT CASE (Reverse), and experiencing some issues:
      > >
      > > My Code:
      > >
      > > Select Case True
      > > Case (strLink_e="" AND strLink_f="")
      > > 'ERROR message
      > > Case (strLink_f="")
      > > 'User has entered an English URL string into Textbox
      > > Case (strLink_e="")
      > > 'User has entered an French URL string into Textbox
      > > Case Else
      > > 'User has entered into BOTH textboxs
      > > End Select
      > >
      > > Now, I have an Entry form , then a second form once the user has
      > > entered into the first Entry form and clicked the SUBMIT button.
      > >
      > > On all the Case Selects I see my DB working from the functionality of
      > > each Case Select. However , I am experiencing a problem with the
      > > second form page displaying itself for either just an English entriy
      > > OR just a French entry...but when BOTH are entered.it works great
      > > (is displayed)
      > >
      > > Any ideas why this would only work for BOTH , and not work for one OR
      > > the other?
      > >
      > > So, just to recap.
      > >
      > > I have an Entry form:
      > >
      > > Submit button
      > >
      > > URL English TEXTBOX
      > > URL French TEXTBOX
      > >
      > >
      > > +++++++++++++++ +++++++++++++++ +
      > >
      > > Once the user enters his/her entry and clicks the Submit button,
      > >
      > > Then I have another FORM that is called that will display the URL
      > > entered as well as other info.
      > >
      > > +++++++++++++++ +++++++++++++++ +
      > >
      > > However, this form seems to only reveal itself when the user has
      > > entered into BOTH textboxes...... ..if they enter into one OR the
      > > other.the functionality that sits behind the chosen textbox entry
      > > works fine, yet the second form does not display....
      > >
      > > Do not know why??
      > >
      > > Any ideas?
      > >
      > > Thanks in advance,
      > >
      > > ~Brad
      > >
      > >
      > >
      > >
      > >
      > >
      > > "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
      > > news:e41uYbUfEH A.224@TK2MSFTNG P10.phx.gbl...[color=darkred]
      > >> Evertjan. wrote:
      > >>> Brad wrote on 07 aug 2004 in
      > >>> microsoft.publi c.inetserver.as p.general:
      > >>>
      > >>>> Now for BOTH of the string textbox inputs , it worked well,
      > >>>> but if I just entered on either ENGLISH or FRENCH, well it
      > >>>> would not acknowledge it......
      > >>>>
      > >>>> So I think that maybe I should be using a CASE SELECT..
      > >>>> but now I have no idea how to make that work for my code,
      > >>>
      > >>> Use the "Elseif" clause:
      > >>>
      > >>> If a="" AND b="" Then
      > >>> 'do what needs to be done if both are empty
      > >>> Elseif a="" Then
      > >>> 'do what needs to be done if only a is empty
      > >>> Elseif b="" Then
      > >>> 'do what needs to be done if only b is empty
      > >>> Else
      > >>> 'do what needs to be done if both are filled
      > >>> End If
      > >>>
      > >>> The 'select case' is never necessary, it only gives a
      > >>> better visual appearance and preferably one variable to
      > >>> be tested for a lot of values and intervals.
      > >>>
      > >>
      > >> The advantage of select case is that it utilizes short-circuit
      > >> evaluation, as opposed to If, in which all expressions are
      > >> evaluated, which can lead to errors if any of the expressions
      > >> generate errors depending on the results of earlier evaluations. I
      > >> realize that this does not apply to this situation: neither a="" nor
      > >> b="" can generate an error so If a="" AND b="" Then is a safe
      > >> expression to use. If you were trying to evauate whether an object
      > >> variable was empty, Nothing, contained Null, or contained an empty
      > >> string, you would have to resort to nesting your boolean comparisons
      > >> to avoid errors. Using Select Case, however, no nesting is
      > >> necessary. For example, with recordsets, nested if statements are
      > >> often used:
      > >>
      > >> if not rs.eof then
      > >> if rs(0) is null then
      > >> elseif rs(0) ="" then
      > >> else
      > >> end if
      > >> end if
      > >>
      > >> The nesting can get deep and is very often difficult to debug. Using
      > >> Select Case, however:
      > >>
      > >> Select Case True
      > >> Case rs.eof
      > >> 'code to handle empty recordset
      > >> Case rs(0) is Null
      > >> 'code to handle case where the field contains null
      > >> Case rs(0) = ""
      > >> 'code to handle case where the field contains ""
      > >> Case Else
      > >> 'code which will only run when the field contains a value
      > >> End Case
      > >>
      > >>
      > >> HTH,
      > >> Bob Barrows
      > >>
      > >> --
      > >> 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"[/color][/color]
      >
      > --
      > 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"
      >
      >[/color]


      Comment

      • Brad

        #18
        Re: What the H_ _ _ am I doing wrong????

        Thanks for your input,

        Very much appraciated,

        I figured out my problem, via debugging the page, my SLECT CASE , nor
        original IF ELSEIF, were not where the problem arose. It was a variable
        that was not being seen

        Thanbks again,

        ~BRAD

        "Bã§TãRÐ" <nobody@msn.com > wrote in message
        news:tv3gh0hv3d b6nler05fs7gm6p 3rfquai5p@4ax.c om...[color=blue]
        > case info is usually sent vit the url in a querystring or in a hidden form[/color]
        variable. I'll do the querystring example for you but the hidden form field
        is just as easy.[color=blue]
        > the Url you are passing http://www.somedomain.com?lan=English
        >
        > select case request.queryst ring("lan")
        >
        > case "English"
        > do something here
        > case "French"
        > do something here
        > case else
        > do something here
        > end select
        >
        > thats pretty much it - the case else statement is a default if nothing[/color]
        else is chosen[color=blue]
        >
        > Hope that helps
        > - Bastard
        >
        >
        >
        > On Sat, 7 Aug 2004 17:21:54 -0400, "Brad" <info@webdevcre ations.com>[/color]
        wrote:[color=blue]
        >[color=green]
        > >This entire thing is rather embarrassing as I cannto get it to work.
        > >
        > >I have 2 input strings that will contain URL's (the contents of the[/color][/color]
        textbox[color=blue][color=green]
        > >strings is a non-issue.
        > >
        > >I have to allow the user to be able to enter into JUST the English OR[/color][/color]
        Just[color=blue][color=green]
        > >the FRENCH or be able to Enter into BOTH ENGLISH and FRENCH
        > >
        > >I was using an IF ELSE statement but was having a hard time with it, as[/color][/color]
        the[color=blue][color=green]
        > >scenerio's conflicted.
        > >
        > >Example:
        > >
        > >If strEnglish<>emp ty AND strFrench <>empty Then 'Both have something[/color][/color]
        inside[color=blue][color=green]
        > >them
        > >'ENTER BOTH INTO DB
        > >End If
        > >
        > >If strEnglish<>emp ty Then 'Just English has something
        > >inside it
        > >'ENTER JUST THE ENGLISH
        > >End If
        > >
        > >If strFrench<>empt y Then 'Just French has something
        > >inside it
        > >'ENTER JUST THE FRENCH
        > >End If
        > >
        > >
        > >Now for BOTH of the string textbox inputs , it worked well, but if I just
        > >entered on either ENGLISH or FRENCH, well it would not acknowledge[/color][/color]
        it......[color=blue][color=green]
        > >
        > >So I think that maybe I should be using a CASE SELECT..but now I have no
        > >idea how to make that work for my code, especially in ASP.
        > >
        > >SAD yet true...but willing to learn how to make it work..........b ut have
        > >yet to find an example that will make me understand..per haps I am making[/color][/color]
        it[color=blue][color=green]
        > >harder than it is...a usual problem of mine.;))
        > >
        > >Can someone help me out here, as I am having a hard time to get this to
        > >work.
        > >
        > >Thanks in advance,
        > >
        > >~Brad (NEWBIE to ASP CASE Selects)
        > >
        > >"Newbie" <Newbie@helpme. com> wrote in message
        > >news:Y0bRc.504 93$Vm1.1312419@ news20.bellglob al.com...[color=darkred]
        > >> Dear friends,
        > >>
        > >> I am having a hard time understanding how to use a SELECT CASE in ASP.[/color][/color][/color]
        I[color=blue][color=green][color=darkred]
        > >> have used it in VB but never in ASP scripting.
        > >>
        > >> Scenerio:
        > >>
        > >> I have 2 textboxes on a form that I have to allow entry to one or the[/color]
        > >other[color=darkred]
        > >> or Both at the same time. Now I tried to use an If ElseIf but it got[/color][/color][/color]
        too[color=blue][color=green][color=darkred]
        > >> hard to track, so now I am using a SELECT CASE Statement.
        > >>
        > >> TEXBOX1 named strEnglish
        > >> TEXBOX2 named strFrench
        > >>
        > >> My code:
        > >> <%
        > >> strEnglish=Requ est.Form("strEn glish")
        > >> strFrench=Reque st.Form("strFre nch")
        > >>
        > >> Select Case
        > >>
        > >> Then I have no idea how to go from here, because I have 2 input[/color][/color][/color]
        textboxes[color=blue][color=green]
        > >to[color=darkred]
        > >> follow.
        > >>
        > >>
        > >> I found this example but I do not know how to apply it to my situation[/color][/color][/color]
        as[color=blue][color=green]
        > >I[color=darkred]
        > >> have to folow 2 textbox entries.
        > >>
        > >> <%
        > >> UserName=reques t.form("UserNam e")
        > >> Select Case UserName
        > >> Case "Kathi"
        > >> Msg = "You deserve a break. Take the day off!"
        > >> Case "JD","Anne"
        > >> Msg = "Don't forget to call Kathi today!"
        > >> Case Else
        > >> Msg = "Do I know you?"
        > >> End Select
        > >> response.write Msg
        > >> %>
        > >>
        > >> Can someone please help me out, a known tutorial, perhaps an example or[/color]
        > >just[color=darkred]
        > >> plain good ole help please??
        > >>
        > >> Thanks in advance,
        > >>
        > >> ~Newbie
        > >>
        > >>[/color]
        > >[/color]
        >[/color]


        Comment

        Working...