Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to stop a method when recieving an error?

how to stop a method when recieving an error?

Scheduled Pinned Locked Moved C#
helpquestiontutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kharr1027
    wrote on last edited by
    #1

    here is what i have and what is happening. I have a main form then another form opens when user clicks the add button. on this form when you add the new information an error check is suppose to run. my problem is i need the error check to stop running and leave the focus on the 2nd form to show where the error is. instead it wants to go back to the main form and finish executing the code that was started when the 2nd form opened! any suggestions thanks

    I M 3 Replies Last reply
    0
    • K kharr1027

      here is what i have and what is happening. I have a main form then another form opens when user clicks the add button. on this form when you add the new information an error check is suppose to run. my problem is i need the error check to stop running and leave the focus on the 2nd form to show where the error is. instead it wants to go back to the main form and finish executing the code that was started when the 2nd form opened! any suggestions thanks

      I Offline
      I Offline
      Ista
      wrote on last edited by
      #2

      try using a try/catch block on the code in question I'm not an expert yet, but I play one at work. Yeah and here too.

      K 1 Reply Last reply
      0
      • I Ista

        try using a try/catch block on the code in question I'm not an expert yet, but I play one at work. Yeah and here too.

        K Offline
        K Offline
        kharr1027
        wrote on last edited by
        #3

        that is not quite what i am looking to do. i believe a try catch is for debugging your own code sort of.....i need am trying to throw messages to the user if there input is wrong. thanks for the help though

        I 1 Reply Last reply
        0
        • K kharr1027

          that is not quite what i am looking to do. i believe a try catch is for debugging your own code sort of.....i need am trying to throw messages to the user if there input is wrong. thanks for the help though

          I Offline
          I Offline
          Ista
          wrote on last edited by
          #4

          well its about validation just because you use a try catch doesnt mean you do or dont have to throw a message. Obciously if there is an error you need to catch it and determine what is wrong and how to resolve the issue I'm not an expert yet, but I play one at work. Yeah and here too.

          1 Reply Last reply
          0
          • K kharr1027

            here is what i have and what is happening. I have a main form then another form opens when user clicks the add button. on this form when you add the new information an error check is suppose to run. my problem is i need the error check to stop running and leave the focus on the 2nd form to show where the error is. instead it wants to go back to the main form and finish executing the code that was started when the 2nd form opened! any suggestions thanks

            I Offline
            I Offline
            Ista
            wrote on last edited by
            #5

            try opening the form like this Form2 fm2 = new Form2(); Form2.ShowDialog(); I'm not an expert yet, but I play one at work. Yeah and here too.

            1 Reply Last reply
            0
            • K kharr1027

              here is what i have and what is happening. I have a main form then another form opens when user clicks the add button. on this form when you add the new information an error check is suppose to run. my problem is i need the error check to stop running and leave the focus on the 2nd form to show where the error is. instead it wants to go back to the main form and finish executing the code that was started when the 2nd form opened! any suggestions thanks

              M Offline
              M Offline
              monrobot13
              wrote on last edited by
              #6

              If you could post some code it might help - monrobot13

              K 1 Reply Last reply
              0
              • M monrobot13

                If you could post some code it might help - monrobot13

                K Offline
                K Offline
                kharr1027
                wrote on last edited by
                #7

                thanks but i already figured it out :) thanks for the interest thought i am sure i will be posting more questions in the future!

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups