SELECT CASE in ASP???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie

    SELECT CASE in ASP???

    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 other
    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 to
    follow.


    I found this example but I do not know how to apply it to my situation as I
    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 just
    plain good ole help please??

    Thanks in advance,

    ~Newbie


  • Evertjan.

    #2
    Re: SELECT CASE in ASP???

    Newbie wrote on 07 aug 2004 in microsoft.publi c.inetserver.as p.general:
    [color=blue]
    >
    > 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
    > other 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 to follow.[/color]

    It is not that I cannot dint a solution using select case in this case,
    but it seems far more useful to know what you want to do with the two
    strings.

    Probably you do not want to use select case after all!!

    <%
    strEnglish=Requ est.Form("strEn glish")
    strFrench=Reque st.Form("strFre nch")

    if strEnglish = strFrench then
    t="This is very improbable"
    else
    t="Two different languages usually produce different strings"
    end if
    response.write t
    %>

    not tested, but it should be the same as:

    <%
    strEnglish=Requ est.Form("strEn glish")
    strFrench=Reque st.Form("strFre nch")

    select case strEnglish
    case strFrench
    t="This is very improbable"
    case else
    t="Two different languages usually produce different strings"
    end select
    response.write t
    %>






    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • dlbjr

      #3
      Re: SELECT CASE in ASP???

      Function GetResult(str1, str2)
      strkey = Trim(str1) & Trim(str2)
      Select Case strkey
      Case "WhatEver1"
      GetResult = "Something1 "
      Case "WhatEver2"
      GetResult = "Something2 "
      Case "WhatEver3"
      GetResult = "Something3 "
      Case "WhatEver4"
      GetResult = "Something4 "
      End Select
      End Function

      dlbjr
      Pleading sagacious indoctrination!


      Comment

      • Brad

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

        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.5049 3$Vm1.1312419@n ews20.bellgloba l.com...[color=blue]
        > 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=blue]
        > 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=blue]
        > follow.
        >
        >
        > I found this example but I do not know how to apply it to my situation as[/color]
        I[color=blue]
        > 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=blue]
        > plain good ole help please??
        >
        > Thanks in advance,
        >
        > ~Newbie
        >
        >[/color]


        Comment

        • Brad

          #5
          Re: SELECT CASE in ASP???

          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)





          "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
          news:Xns953EEA5 FC82E2eejj99@19 4.109.133.29...[color=blue]
          > Newbie wrote on 07 aug 2004 in microsoft.publi c.inetserver.as p.general:
          >[color=green]
          > >
          > > 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
          > > other 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 to follow.[/color]
          >
          > It is not that I cannot dint a solution using select case in this case,
          > but it seems far more useful to know what you want to do with the two
          > strings.
          >
          > Probably you do not want to use select case after all!!
          >
          > <%
          > strEnglish=Requ est.Form("strEn glish")
          > strFrench=Reque st.Form("strFre nch")
          >
          > if strEnglish = strFrench then
          > t="This is very improbable"
          > else
          > t="Two different languages usually produce different strings"
          > end if
          > response.write t
          > %>
          >
          > not tested, but it should be the same as:
          >
          > <%
          > strEnglish=Requ est.Form("strEn glish")
          > strFrench=Reque st.Form("strFre nch")
          >
          > select case strEnglish
          > case strFrench
          > t="This is very improbable"
          > case else
          > t="Two different languages usually produce different strings"
          > end select
          > response.write t
          > %>
          >
          >
          >
          >
          >
          >
          > --
          > Evertjan.
          > The Netherlands.
          > (Please change the x'es to dots in my emailaddress)[/color]


          Comment

          • Brad

            #6
            Re: PROBLEM SOLVED :)))

            If strEnglish<>emp ty AND strFrench<>empt y Then
            'Do Both
            End If

            If strEnglish<>emp ty Then
            'Do JUSt the English one
            ElseIF strFrench<>empt y Then
            'Do Just the French one
            End If

            I did not need to use a SELECT CASE........... I think I must have missed
            something when Iw first wrote the IF ELSEIF

            Well now it works for all scenerios,

            Thanks again to all those for your input.......... ..it is always helpful

            ~Brad



            "Brad" <info@webdevcre ations.com> wrote in message
            news:QJbRc.5051 4$Vm1.1323411@n ews20.bellgloba l.com...[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[/color]
            textbox[color=blue]
            > 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[/color]
            the[color=blue]
            > scenerio's conflicted.
            >
            > Example:
            >
            > If strEnglish<>emp ty AND strFrench <>empty Then 'Both have something[/color]
            inside[color=blue]
            > 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]
            it......[color=blue]
            >
            > 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]
            it[color=blue]
            > 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.5049 3$Vm1.1312419@n ews20.bellgloba l.com...[color=green]
            > > Dear friends,
            > >
            > > I am having a hard time understanding how to use a SELECT CASE in ASP.[/color][/color]
            I[color=blue][color=green]
            > > 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[/color][/color]
            too[color=blue][color=green]
            > > 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]
            textboxes[color=blue]
            > to[color=green]
            > > follow.
            > >
            > >
            > > I found this example but I do not know how to apply it to my situation[/color][/color]
            as[color=blue]
            > 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

            • Chris Hohmann

              #7
              Re: PROBLEM SOLVED :)))

              "Brad" <info@webdevcre ations.com> wrote in message
              news:v6cRc.5052 3$Vm1.1328205@n ews20.bellgloba l.com...[color=blue]
              > If strEnglish<>emp ty AND strFrench<>empt y Then
              > 'Do Both
              > End If
              >
              > If strEnglish<>emp ty Then
              > 'Do JUSt the English one
              > ElseIF strFrench<>empt y Then
              > 'Do Just the French one
              > End If
              >
              > I did not need to use a SELECT CASE........... I think I must have missed
              > something when Iw first wrote the IF ELSEIF
              >
              > Well now it works for all scenerios,
              >
              > Thanks again to all those for your input.......... ..it is always helpful[/color]

              Doesn't the above logic indicate that all three cases (English, French and
              both) will be executed when both English and French are present? I think
              this is the logic you're after:

              If Len(strEnglish & strFrench)=0 Then
              'Neither is present
              ElseIf Len(strEnglish) =0 Then
              'French
              ElseIf Len(strFrench)= 0 Then
              'English
              Else
              'Both
              End If

              IMPORTANT NOTE: Pay special attention to "ElseIf". It's one word, no spaces.
              It's fundamentally different from "Else If", which denotes nested IF
              statements. Also, are you actually using the IsEmpty() inspection function?
              It doesn't do what I think you think it does. :)


              Comment

              • Brad

                #8
                Re: Chris ~ Thanks :)))

                Chris,

                I ran into problems with my Logic thinking of If Else, rather than
                IFELSE.....find ing out the hard way that my If strEnglish<>emp ty did not
                work, nor did the one for the french......

                So I finally ended up with what yoru logic depicted.

                Thanks for the help [IE: your Important Note;)) ],

                ~Brad



                "Chris Hohmann" <nospam@thankyo u.com> wrote in message
                news:uvDzl5MfEH A.2812@tk2msftn gp13.phx.gbl...[color=blue]
                > "Brad" <info@webdevcre ations.com> wrote in message
                > news:v6cRc.5052 3$Vm1.1328205@n ews20.bellgloba l.com...[color=green]
                > > If strEnglish<>emp ty AND strFrench<>empt y Then
                > > 'Do Both
                > > End If
                > >
                > > If strEnglish<>emp ty Then
                > > 'Do JUSt the English one
                > > ElseIF strFrench<>empt y Then
                > > 'Do Just the French one
                > > End If
                > >
                > > I did not need to use a SELECT CASE........... I think I must have[/color][/color]
                missed[color=blue][color=green]
                > > something when Iw first wrote the IF ELSEIF
                > >
                > > Well now it works for all scenerios,
                > >
                > > Thanks again to all those for your input.......... ..it is always helpful[/color]
                >
                > Doesn't the above logic indicate that all three cases (English, French and
                > both) will be executed when both English and French are present? I think
                > this is the logic you're after:
                >
                > If Len(strEnglish & strFrench)=0 Then
                > 'Neither is present
                > ElseIf Len(strEnglish) =0 Then
                > 'French
                > ElseIf Len(strFrench)= 0 Then
                > 'English
                > Else
                > 'Both
                > End If
                >
                > IMPORTANT NOTE: Pay special attention to "ElseIf". It's one word, no[/color]
                spaces.[color=blue]
                > It's fundamentally different from "Else If", which denotes nested IF
                > statements. Also, are you actually using the IsEmpty() inspection[/color]
                function?[color=blue]
                > It doesn't do what I think you think it does. :)
                >
                >[/color]


                Comment

                • Brad

                  #9
                  Re: Chris ~ Thanks :)))

                  Chris,

                  Seems the logic is not working........ ......

                  It works very well for BOTH, but not for the rest, any ideas?

                  Perhaps I should use a CASE SELECT

                  How can I convert the logic you wrote to CASE SELECT

                  I cannot make it work with the IFELSE, it seems to crap out on the
                  individual entries, while the BOTh entries works fine.

                  Any ideas?

                  Thanks in advance,

                  ~Brad


                  "Brad" <info@webdevcre ations.com> wrote in message
                  news:CXeRc.4823 1$Jq2.2266010@n ews20.bellgloba l.com...[color=blue]
                  > Chris,
                  >
                  > I ran into problems with my Logic thinking of If Else, rather than
                  > IFELSE.....find ing out the hard way that my If strEnglish<>emp ty did not
                  > work, nor did the one for the french......
                  >
                  > So I finally ended up with what yoru logic depicted.
                  >
                  > Thanks for the help [IE: your Important Note;)) ],
                  >
                  > ~Brad
                  >
                  >
                  >
                  > "Chris Hohmann" <nospam@thankyo u.com> wrote in message
                  > news:uvDzl5MfEH A.2812@tk2msftn gp13.phx.gbl...[color=green]
                  > > "Brad" <info@webdevcre ations.com> wrote in message
                  > > news:v6cRc.5052 3$Vm1.1328205@n ews20.bellgloba l.com...[color=darkred]
                  > > > If strEnglish<>emp ty AND strFrench<>empt y Then
                  > > > 'Do Both
                  > > > End If
                  > > >
                  > > > If strEnglish<>emp ty Then
                  > > > 'Do JUSt the English one
                  > > > ElseIF strFrench<>empt y Then
                  > > > 'Do Just the French one
                  > > > End If
                  > > >
                  > > > I did not need to use a SELECT CASE........... I think I must have[/color][/color]
                  > missed[color=green][color=darkred]
                  > > > something when Iw first wrote the IF ELSEIF
                  > > >
                  > > > Well now it works for all scenerios,
                  > > >
                  > > > Thanks again to all those for your input.......... ..it is always[/color][/color][/color]
                  helpful[color=blue][color=green]
                  > >
                  > > Doesn't the above logic indicate that all three cases (English, French[/color][/color]
                  and[color=blue][color=green]
                  > > both) will be executed when both English and French are present? I think
                  > > this is the logic you're after:
                  > >
                  > > If Len(strEnglish & strFrench)=0 Then
                  > > 'Neither is present
                  > > ElseIf Len(strEnglish) =0 Then
                  > > 'French
                  > > ElseIf Len(strFrench)= 0 Then
                  > > 'English
                  > > Else
                  > > 'Both
                  > > End If
                  > >
                  > > IMPORTANT NOTE: Pay special attention to "ElseIf". It's one word, no[/color]
                  > spaces.[color=green]
                  > > It's fundamentally different from "Else If", which denotes nested IF
                  > > statements. Also, are you actually using the IsEmpty() inspection[/color]
                  > function?[color=green]
                  > > It doesn't do what I think you think it does. :)
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Evertjan.

                    #10
                    Re: SELECT CASE in ASP???

                    Brad wrote on 07 aug 2004 in
                    microsoft.publi c.inetserver.as p.general:
                    [color=blue]
                    > 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,[/color]

                    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 'if-then..elseif-then..else..end if' is also pleasing
                    to the eye,[and therefore easily debuggable IMHO,]
                    if properly indented.
                    [color=blue]
                    > especially in ASP.[/color]

                    ASP is not a scripting language. We are talking vbscript
                    here, and wether this is done in a serverside ASP platform
                    or in IE clientside vbscript does not matter, if you do not
                    use specific ASP objects like Response or Server. Those
                    objects are not part of vbscript and are also available in
                    ASP j(ava)script etc.

                    --
                    Evertjan.
                    The Netherlands.
                    (Please change the x'es to dots in my emailaddress)

                    Comment

                    • Bob Barrows [MVP]

                      #11
                      Re: SELECT CASE in ASP???

                      Evertjan. wrote:[color=blue]
                      > Brad wrote on 07 aug 2004 in
                      > microsoft.publi c.inetserver.as p.general:
                      >[color=green]
                      >> 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,[/color]
                      >
                      > 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.
                      >[/color]

                      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"


                      Comment

                      • Evertjan.

                        #12
                        Re: SELECT CASE in ASP???

                        Bob Barrows [MVP] wrote on 08 aug 2004 in
                        microsoft.publi c.inetserver.as p.general:[color=blue]
                        > 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[/color]

                        Ah, the "reversed select case" method. ;-)

                        I think, Bob, that also here 'Select Case' is just a shorthand version if
                        the 'elsif', also here no nesting is necessary:

                        If rs.eof Then
                        'code to handle empty recordset
                        Elseif rs(0) is Null Then
                        'code to handle case where the field contains null
                        Elseif rs(0) = "" Then
                        'code to handle case where the field contains ""
                        Else
                        'code which will only run when the field contains a value
                        End If

                        --
                        Evertjan.
                        The Netherlands.
                        (Please change the x'es to dots in my emailaddress)

                        Comment

                        • Roland Hall

                          #13
                          Re: Chris ~ Thanks :)))

                          "Brad" wrote in message
                          news:_ofRc.4866 6$Jq2.2272424@n ews20.bellgloba l.com...
                          : Seems the logic is not working........ ......

                          You're right. Why would anyone need to enter a form in two languages?

                          However...

                          dim strEnglish, strFrench, strLanguage
                          strEnglish = ""
                          strFrench = ""
                          strLanguage = "both"

                          strEnglish=Requ est.Form("strEn glish")
                          strFrench=Reque st.Form("strFre nch")

                          if strEnglish <> "" and strFrench <> "" then
                          strLanguage = "both"
                          elseif strEnglish <> "" then
                          strLanguage = "English"
                          elseif strFrench <> "" then
                          strLanguage = "French"
                          else
                          ' some other language
                          end if

                          or modify the form to accept English, French or both [English and French].
                          Then...

                          dim strLanguage
                          strLanguage = Response.Form(" strLanguage")

                          select case strLanguage
                          case "both"
                          ' English and French
                          case "English"
                          ' English
                          case "French"
                          ' French
                          case else
                          ' Some other language
                          end select

                          HTH...

                          --
                          Roland Hall
                          /* This information is distributed in the hope that it will be useful, but
                          without any warranty; without even the implied warranty of merchantability
                          or fitness for a particular purpose. */
                          Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
                          WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
                          MSDN Library - http://msdn.microsoft.com/library/default.asp


                          Comment

                          • Brad

                            #14
                            Re: Bob ~~ SELECT CASE in ASP???

                            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=blue]
                            > Evertjan. wrote:[color=green]
                            > > Brad wrote on 07 aug 2004 in
                            > > microsoft.publi c.inetserver.as p.general:
                            > >[color=darkred]
                            > >> 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,[/color]
                            > >
                            > > 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.
                            > >[/color]
                            >
                            > 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[/color]
                            to[color=blue]
                            > errors if any of the expressions generate errors depending on the results[/color]
                            of[color=blue]
                            > 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[/color]
                            Select[color=blue]
                            > 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]


                            Comment

                            • Bob Barrows [MVP]

                              #15
                              Re: Bob ~~ SELECT CASE in ASP???

                              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=blue]
                              > 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=green]
                              >> Evertjan. wrote:[color=darkred]
                              >>> 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.
                              >>>[/color]
                              >>
                              >> 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"


                              Comment

                              Working...