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. Visual Basic
  4. over/under flow question

over/under flow question

Scheduled Pinned Locked Moved Visual Basic
helpquestiontutorial
4 Posts 2 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.
  • J Offline
    J Offline
    justmeTW
    wrote on last edited by
    #1

    I basically have three problems here. First I have created a Calculator but it uses error handlers. I have searched to find codes to create a overflow exception code and underflow exception but found no luck. What I want to do is create an overflow and underflow code so that if the interger is over or under the input then it will bypass the following message: "Unhandled exception of type "System.Overflow" occurred in microsoft.visualbasic.dll" And the same for the underflow exception error too. The last problem I need help on is creating another code so that if the user inputs 1.1.1.1 then an error message will occur. The user is only allowed to enter one decimal point and if the user inputs more than one in the text field then I would like an error message to appear. I know how to create an error message but don't know what code to use if there is more than one decimal inputted. I would also like all the codes to use the Try/Catch statements. Can anyone help me? Thanks in advance

    A 1 Reply Last reply
    0
    • J justmeTW

      I basically have three problems here. First I have created a Calculator but it uses error handlers. I have searched to find codes to create a overflow exception code and underflow exception but found no luck. What I want to do is create an overflow and underflow code so that if the interger is over or under the input then it will bypass the following message: "Unhandled exception of type "System.Overflow" occurred in microsoft.visualbasic.dll" And the same for the underflow exception error too. The last problem I need help on is creating another code so that if the user inputs 1.1.1.1 then an error message will occur. The user is only allowed to enter one decimal point and if the user inputs more than one in the text field then I would like an error message to appear. I know how to create an error message but don't know what code to use if there is more than one decimal inputted. I would also like all the codes to use the Try/Catch statements. Can anyone help me? Thanks in advance

      A Offline
      A Offline
      apferreira
      wrote on last edited by
      #2

      justmeTW wrote: What I want to do is create an overflow and underflow code so that if the interger is over or under the input then it will bypass the following message: Use catch statements that target the System.OverflowException class to display a personalized message on overflow errors. justmeTW wrote: if the user inputs 1.1.1.1 then an error message will occur. I would suggest using an extended textobx control that would validate user input instead of using try/catch clauses.

      J 1 Reply Last reply
      0
      • A apferreira

        justmeTW wrote: What I want to do is create an overflow and underflow code so that if the interger is over or under the input then it will bypass the following message: Use catch statements that target the System.OverflowException class to display a personalized message on overflow errors. justmeTW wrote: if the user inputs 1.1.1.1 then an error message will occur. I would suggest using an extended textobx control that would validate user input instead of using try/catch clauses.

        J Offline
        J Offline
        justmeTW
        wrote on last edited by
        #3

        So to use the try/catch for the over/underflow the code should be something like this: Try myAnswer = myNumber1 / myNumber2 MessageBox.Show(msg1, "Invalid format") Catch ex1 as System.OverflowException msg1 = "Error: Invalid Arguement," & vbCrLt _ & ex1.message End Try Is this what I would use to bypass the overflow and underflow error exception? apferreira wrote: I would suggest using an extended textobx control that would validate user input instead of using try/catch clauses. Can you go a little more into depth? And if possible an example code. If I see the code I understand more. Thanks so much for the help

        A 1 Reply Last reply
        0
        • J justmeTW

          So to use the try/catch for the over/underflow the code should be something like this: Try myAnswer = myNumber1 / myNumber2 MessageBox.Show(msg1, "Invalid format") Catch ex1 as System.OverflowException msg1 = "Error: Invalid Arguement," & vbCrLt _ & ex1.message End Try Is this what I would use to bypass the overflow and underflow error exception? apferreira wrote: I would suggest using an extended textobx control that would validate user input instead of using try/catch clauses. Can you go a little more into depth? And if possible an example code. If I see the code I understand more. Thanks so much for the help

          A Offline
          A Offline
          apferreira
          wrote on last edited by
          #4

          The MessageBox.Show method should be inside the catch statament, i.e. Try var1=number1/number2 Catch e As System.OverflowException MessageBox.Show("Error:Invalid Argument" & e.Message","Invalid format") End Try As for the extended textbox control that validates user input, I suggest you read the following CodeProject articles: Validating TextBoxControls[^] Validating TextBox[^] And for a more general view on custom control development, I suggest the following MSDN article Developing Custom Windows Controls using Visual Basic NET[^]

          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