try catch question

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

    #1

    try catch question

    I know this will sound like a really stupid question, but here goes.
    I am in the middle of debugging someone else's code and am getting
    more confused by the second. Does the try catch require an "end
    Try"? There are try's and catches everywhere, but no end trys.

    If when you get finished having a good laugh and feel up to posting a
    reply, I would be most grateful for any advice.

    Oh and if anyone knows of a quick way to check that braces match up -
    I think the squiggly braces aren't always paired as they should be.

    Thanks,
    Dawn

  • Michael D. Ober

    #2
    Re: try catch question

    In VB, the complete construction is

    Try
    <protected statements>
    Catch (optional exception variable as exception type)
    <error handler>
    Finally
    <cleanup statements that will always run>
    End Try.

    C# uses

    try {
    <protected statements>
    }catch (optional exception variable as exception type) {
    <error handler>
    }finally {
    <cleanup statements that will always run>
    }

    Mike.

    "dawn13" <dawn.coulter@w rightind.comwro te in message
    news:1177614452 .082947.81270@r 3g2000prh.googl egroups.com...
    >I know this will sound like a really stupid question, but here goes.
    I am in the middle of debugging someone else's code and am getting
    more confused by the second. Does the try catch require an "end
    Try"? There are try's and catches everywhere, but no end trys.
    >
    If when you get finished having a good laugh and feel up to posting a
    reply, I would be most grateful for any advice.
    >
    Oh and if anyone knows of a quick way to check that braces match up -
    I think the squiggly braces aren't always paired as they should be.
    >
    Thanks,
    Dawn
    >

    Comment

    • Rory Becker

      #3
      Re: try catch question

      I know this will sound like a really stupid question, but here goes. I
      am in the middle of debugging someone else's code and am getting more
      confused by the second. Does the try catch require an "end Try"?
      There are try's and catches everywhere, but no end trys.
      >
      If when you get finished having a good laugh and feel up to posting a
      reply, I would be most grateful for any advice.
      >
      Oh and if anyone knows of a quick way to check that braces match up -
      I think the squiggly braces aren't always paired as they should be.
      Hey Dawn I think you're reading c# code not vb.net

      So your code might look like

      -------------------------------------------------------------
      try
      {
      // try something
      }
      catch exception ex
      {
      // do some catch stuff
      }
      -------------------------------------------------------------

      However the nature of c# allows for the braces to be placed on other lines
      thus...
      -------------------------------------------------------------
      try {
      // try something
      }
      catch exception ex {
      // do some catch stuff
      }
      -------------------------------------------------------------

      Note that the opening braces are not parrallel with the closing ones.

      In this case (c#), the end brace '}' is equivilent to 'End Try'

      I hope this helps

      --
      Rory


      Comment

      • dawn13

        #4
        Re: try catch question

        On Apr 26, 2:23 pm, Rory Becker <RoryBec...@new sgroup.nospamwr ote:
        I know this will sound like a really stupid question, but here goes. I
        am in the middle of debugging someone else's code and am getting more
        confused by the second. Does the try catch require an "end Try"?
        There are try's and catches everywhere, but no end trys.
        >
        If when you get finished having a good laugh and feel up to posting a
        reply, I would be most grateful for any advice.
        >
        Oh and if anyone knows of a quick way to check that braces match up -
        I think the squiggly braces aren't always paired as they should be.
        >
        Hey Dawn I think you're reading c# code not vb.net
        >
        So your code might look like
        >
        -------------------------------------------------------------
        try
        {
        // try something}
        >
        catch exception ex
        {
        // do some catch stuff}
        >
        -------------------------------------------------------------
        >
        However the nature of c# allows for the braces to be placed on other lines
        thus...
        -------------------------------------------------------------
        try {
        // try something}
        >
        catch exception ex {
        // do some catch stuff}
        >
        -------------------------------------------------------------
        >
        Note that the opening braces are not parrallel with the closing ones.
        >
        In this case (c#), the end brace '}' is equivilent to 'End Try'
        >
        I hope this helps
        >
        --
        Rory
        All things are possible, and I am fairly new to .NET, however all of
        the files in the project are named with VB conventions. All my forms
        are something.vb, and I thought that indicated a VB.NET program.
        Doesn't C# use a different naming convention; I thought .cs, but has
        been awhile since I played around with.

        Is it possible to use C# conventions in a vb.net program? Wouldn't it
        cause a problem?

        If I am understanding the answers posted here, VB does require a End
        Try, but C# does not. That was my understanding as well. OK. So how
        do I know for sure whether I am indeed working in VB or C#?

        Thanks for the help,
        Dawn

        Comment

        • Rory Becker

          #5
          Re: try catch question

          All things are possible, and I am fairly new to .NET, however all of
          the files in the project are named with VB conventions. All my forms
          are something.vb, and I thought that indicated a VB.NET program.
          Doesn't C# use a different naming convention; I thought .cs, but has
          been awhile since I played around with.
          >
          Is it possible to use C# conventions in a vb.net program? Wouldn't it
          cause a problem?
          >
          If I am understanding the answers posted here, VB does require a End
          Try, but C# does not. That was my understanding as well. OK. So how
          do I know for sure whether I am indeed working in VB or C#?
          >
          The best way is to paste us some code and we'll have a look for you

          The example try catch would do.

          --
          Rory


          Comment

          • Cor Ligthert [MVP]

            #6
            Re: try catch question

            Rory and dawn,

            Most of us in the microsoft newsgroup use Microsoft (upper) mailconventions
            instead of the Apple/Netscape this means that we don't have to read to
            endless messages. We aint anymore in the time that a message was 2 lines so
            you could easily concat below that. Will you please do that to?

            Thanks in advance,

            Cor

            "Rory Becker" <RoryBecker@new sgroup.nospamsc hreef in bericht
            news:b0ac48a09f 5e8c95673b4a20d 00@msnews.micro soft.com...
            >All things are possible, and I am fairly new to .NET, however all of
            >the files in the project are named with VB conventions. All my forms
            >are something.vb, and I thought that indicated a VB.NET program.
            >Doesn't C# use a different naming convention; I thought .cs, but has
            >been awhile since I played around with.
            >>
            >Is it possible to use C# conventions in a vb.net program? Wouldn't it
            >cause a problem?
            >>
            >If I am understanding the answers posted here, VB does require a End
            >Try, but C# does not. That was my understanding as well. OK. So how
            >do I know for sure whether I am indeed working in VB or C#?
            >>
            >
            The best way is to paste us some code and we'll have a look for you
            >
            The example try catch would do.
            >
            --
            Rory
            >
            >

            Comment

            • Robin Tucker

              #7
              Re: try catch question


              Thats funny Cor. Whenever I post using this convention in other groups, I
              have to put my flame retardant suit on!


              "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
              news:ezFiKXGiHH A.3452@TK2MSFTN GP04.phx.gbl...
              Rory and dawn,
              >
              Most of us in the microsoft newsgroup use Microsoft (upper)
              mailconventions instead of the Apple/Netscape this means that we don't
              have to read to endless messages. We aint anymore in the time that a
              message was 2 lines so you could easily concat below that. Will you please
              do that to?
              >
              Thanks in advance,
              >
              Cor
              >
              "Rory Becker" <RoryBecker@new sgroup.nospamsc hreef in bericht
              news:b0ac48a09f 5e8c95673b4a20d 00@msnews.micro soft.com...
              >>All things are possible, and I am fairly new to .NET, however all of
              >>the files in the project are named with VB conventions. All my forms
              >>are something.vb, and I thought that indicated a VB.NET program.
              >>Doesn't C# use a different naming convention; I thought .cs, but has
              >>been awhile since I played around with.
              >>>
              >>Is it possible to use C# conventions in a vb.net program? Wouldn't it
              >>cause a problem?
              >>>
              >>If I am understanding the answers posted here, VB does require a End
              >>Try, but C# does not. That was my understanding as well. OK. So how
              >>do I know for sure whether I am indeed working in VB or C#?
              >>>
              >>
              >The best way is to paste us some code and we'll have a look for you
              >>
              >The example try catch would do.
              >>
              >--
              >Rory
              >>
              >>
              >
              >

              Comment

              • cj

                #8
                Re: try catch question

                Robin,

                I too get flamed bad when I post at the top in many groups. One group,
                and I don't remember which, someone told me if I didn't have the
                courtesy to post at the bottom that I couldn't post there. When I told
                them my feelings they went on to point out web etiquette articles and
                tried to tell me posting at the bottom was the correct way. But I
                believe like Cor, that top is best and most forums I see post at top
                so.... Anyway because of my experiences I don't say anything when I see
                someone here posting at the bottom.

                Glad to see your actually a top poster at heart. :)


                Robin Tucker wrote:
                Thats funny Cor. Whenever I post using this convention in other groups, I
                have to put my flame retardant suit on!
                >
                >
                "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
                news:ezFiKXGiHH A.3452@TK2MSFTN GP04.phx.gbl...
                >Rory and dawn,
                >>
                >Most of us in the microsoft newsgroup use Microsoft (upper)
                >mailconvention s instead of the Apple/Netscape this means that we don't
                >have to read to endless messages. We aint anymore in the time that a
                >message was 2 lines so you could easily concat below that. Will you please
                >do that to?
                >>
                >Thanks in advance,
                >>
                >Cor
                >>
                >"Rory Becker" <RoryBecker@new sgroup.nospamsc hreef in bericht
                >news:b0ac48a09 f5e8c95673b4a20 d00@msnews.micr osoft.com...
                >>>All things are possible, and I am fairly new to .NET, however all of
                >>>the files in the project are named with VB conventions. All my forms
                >>>are something.vb, and I thought that indicated a VB.NET program.
                >>>Doesn't C# use a different naming convention; I thought .cs, but has
                >>>been awhile since I played around with.
                >>>>
                >>>Is it possible to use C# conventions in a vb.net program? Wouldn't it
                >>>cause a problem?
                >>>>
                >>>If I am understanding the answers posted here, VB does require a End
                >>>Try, but C# does not. That was my understanding as well. OK. So how
                >>>do I know for sure whether I am indeed working in VB or C#?
                >>>>
                >>The best way is to paste us some code and we'll have a look for you
                >>>
                >>The example try catch would do.
                >>>
                >>--
                >>Rory
                >>>
                >>>
                >>
                >
                >

                Comment

                • =?ISO-8859-1?Q?G=F6ran_Andersson?=

                  #9
                  Re: try catch question

                  Cor Ligthert [MVP] wrote:
                  Rory and dawn,
                  >
                  Most of us in the microsoft newsgroup use Microsoft (upper) mailconventions
                  instead of the Apple/Netscape this means that we don't have to read to
                  endless messages. We aint anymore in the time that a message was 2 lines so
                  you could easily concat below that. Will you please do that to?
                  >
                  Thanks in advance,
                  >
                  Cor
                  >
                  Why are you top posting a thread that is not using top posting?

                  I don't care much if a thread uses top posting or bottom posting, as
                  long as the people in the thread can stick to the same style. It's when
                  someone is so rigit that he absolutely have to use his favorite style
                  regardless of what everybody else in the thread is using, that it gets
                  irritating.

                  --
                  Göran Andersson
                  _____
                  Göran Anderssons privata hemsida.

                  Comment

                  • Cor Ligthert [MVP]

                    #10
                    Re: try catch question

                    Goran,

                    As I wrote, I had not any problem with it when messages were 10 lines. I am
                    not starting writing this in this newsgroup, somebody else attended me at
                    the fact that with messages from 500 lines it is no fun anymore everytime to
                    have to scroll to the bottom.

                    I know from myself that I stop earlier to answer the bottom posters than the
                    topposters after a while.
                    However feel free to do it as you want.

                    Cor

                    "Göran Andersson" <guffa@guffa.co mschreef in bericht
                    news:ugccL5PiHH A.4596@TK2MSFTN GP05.phx.gbl...
                    Cor Ligthert [MVP] wrote:
                    >Rory and dawn,
                    >>
                    >Most of us in the microsoft newsgroup use Microsoft (upper)
                    >mailconvention s instead of the Apple/Netscape this means that we don't
                    >have to read to endless messages. We aint anymore in the time that a
                    >message was 2 lines so you could easily concat below that. Will you
                    >please do that to?
                    >>
                    >Thanks in advance,
                    >>
                    >Cor
                    >>
                    >
                    Why are you top posting a thread that is not using top posting?
                    >
                    I don't care much if a thread uses top posting or bottom posting, as long
                    as the people in the thread can stick to the same style. It's when someone
                    is so rigit that he absolutely have to use his favorite style regardless
                    of what everybody else in the thread is using, that it gets irritating.
                    >
                    --
                    Göran Andersson
                    _____
                    http://www.guffa.com

                    Comment

                    • =?ISO-8859-1?Q?G=F6ran_Andersson?=

                      #11
                      Re: try catch question

                      Cor Ligthert [MVP] wrote:
                      Goran,
                      >
                      As I wrote, I had not any problem with it when messages were 10 lines. I am
                      not starting writing this in this newsgroup, somebody else attended me at
                      the fact that with messages from 500 lines it is no fun anymore everytime to
                      have to scroll to the bottom.
                      The solution to that is to quote properly. The problem is not that the
                      reply is at the bottom of the message, it's that the message is too
                      long. The logical solution would be to fix the problem, not to
                      circumvent the problem by introducing another one.
                      I know from myself that I stop earlier to answer the bottom posters than the
                      topposters after a while.
                      And is the reason really that they are posting at the bottom, or that
                      they are quoting to much of the previous conversation? I think that you
                      are focusing on the wrong issue.
                      However feel free to do it as you want.
                      >
                      Cor
                      >
                      "Göran Andersson" <guffa@guffa.co mschreef in bericht
                      news:ugccL5PiHH A.4596@TK2MSFTN GP05.phx.gbl...
                      >Cor Ligthert [MVP] wrote:
                      >>Rory and dawn,
                      >>>
                      >>Most of us in the microsoft newsgroup use Microsoft (upper)
                      >>mailconventio ns instead of the Apple/Netscape this means that we don't
                      >>have to read to endless messages. We aint anymore in the time that a
                      >>message was 2 lines so you could easily concat below that. Will you
                      >>please do that to?
                      >>>
                      >>Thanks in advance,
                      >>>
                      >>Cor
                      >>>
                      >Why are you top posting a thread that is not using top posting?
                      >>
                      >I don't care much if a thread uses top posting or bottom posting, as long
                      >as the people in the thread can stick to the same style. It's when someone
                      >is so rigit that he absolutely have to use his favorite style regardless
                      >of what everybody else in the thread is using, that it gets irritating.
                      >>
                      >--
                      >Göran Andersson
                      >_____
                      >http://www.guffa.com
                      >
                      >

                      --
                      Göran Andersson
                      _____
                      Göran Anderssons privata hemsida.

                      Comment

                      • Tom Shelton

                        #12
                        Re: try catch question

                        On Apr 27, 7:17 am, cj <c...@nospam.no spamwrote:
                        Robin,
                        >
                        I too get flamed bad when I post at the top in many groups. One group,
                        and I don't remember which, someone told me if I didn't have the
                        courtesy to post at the bottom that I couldn't post there. When I told
                        them my feelings they went on to point out web etiquette articles and
                        tried to tell me posting at the bottom was the correct way. But I
                        believe like Cor, that top is best and most forums I see post at top
                        so.... Anyway because of my experiences I don't say anything when I see
                        someone here posting at the bottom.
                        >
                        Glad to see your actually a top poster at heart. :)
                        >
                        >
                        >
                        Robin Tucker wrote:
                        Thats funny Cor. Whenever I post using this convention in other groups, I
                        have to put my flame retardant suit on!
                        >
                        "Cor Ligthert [MVP]" <notmyfirstn... @planet.nlwrote in message
                        news:ezFiKXGiHH A.3452@TK2MSFTN GP04.phx.gbl...
                        Rory and dawn,
                        >
                        Most of us in the microsoft newsgroup use Microsoft (upper)
                        mailconventions instead of the Apple/Netscape this means that we don't
                        have to read to endless messages. We aint anymore in the time that a
                        message was 2 lines so you could easily concat below that. Will you please
                        do that to?
                        >
                        Thanks in advance,
                        >
                        Cor
                        >
                        "Rory Becker" <RoryBec...@new sgroup.nospamsc hreef in bericht
                        >news:b0ac48a09 f5e8c95673b4a20 d00@msnews.micr osoft.com...
                        >>All things are possible, and I am fairly new to .NET, however all of
                        >>the files in the project are named with VB conventions. All my forms
                        >>are something.vb, and I thought that indicated a VB.NET program.
                        >>Doesn't C# use a different naming convention; I thought .cs, but has
                        >>been awhile since I played around with.
                        >
                        >>Is it possible to use C# conventions in a vb.net program? Wouldn't it
                        >>cause a problem?
                        >
                        >>If I am understanding the answers posted here, VB does require a End
                        >>Try, but C# does not. That was my understanding as well. OK. So how
                        >>do I know for sure whether I am indeed working in VB or C#?
                        >
                        >The best way is to paste us some code and we'll have a look for you
                        >
                        >The example try catch would do.
                        >
                        >--
                        >Rory- Hide quoted text -
                        >
                        - Show quoted text -
                        Common Usenet etiquet is to post at the bottom - except for inline
                        replies. This allows the flow of the conversation to be followed,
                        even if you only get a partial message. It helps keep context.

                        Yes, you will see a lot of top posting on microsoft forums, but many
                        people are posting here using outlook express or a web interface.
                        outlook express encourages top posting by automatically putting the
                        cursor on top - most other readers start you at the bottom.

                        I guarentee you that if you go to most non-microsoft forums, you will
                        find that top posting is not appriciated.

                        --
                        Tom Shelton

                        Comment

                        • Robin Tucker

                          #13
                          Re: try catch question

                          Yes, you will see a lot of top posting on microsoft forums, but many
                          people are posting here using outlook express or a web interface.
                          outlook express encourages top posting by automatically putting the
                          cursor on top - most other readers start you at the bottom.
                          Actually that is the main point - its just easier to start typing where-ever
                          the cursor is placed - and yes I used outlook. I didn't try with other
                          newsreaders but its all perfectly understandable I suppose. Of course when
                          quoting as above, its better to post underneath ;).



                          Robin


                          Comment

                          Working...