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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Interger overflow exception

Interger overflow exception

Scheduled Pinned Locked Moved Visual Basic
helpquestion
3 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.
  • D Offline
    D Offline
    djones1941
    wrote on last edited by
    #1

    How do I turn on the integer overflow checking to On, so that I can get a System.OverflowException exception thrown. 'Declare FirstNum and SecondNum variables Dim FirstNum, SecondNum As Short Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Assign text box values to variables Try FirstNum = TextBox1.Text SecondNum = TextBox2.Text Catch When Err.Number = 6 'Overflow error MsgBox("Out of calculators peramiters") Catch When Err.Number = 11 'Division by zero error MsgBox("Can't divide by zero") End Try 'Determine checked button and calculate If RadioButton1.Checked = True Then TextBox3.Text = FirstNum + SecondNum End If If RadioButton2.Checked = True Then TextBox3.Text = FirstNum - SecondNum End If If RadioButton3.Checked = True Then TextBox3.Text = FirstNum * SecondNum End If If RadioButton4.Checked = True Then TextBox3.Text = FirstNum / SecondNum End If End Sub End Class Thanks for the Help Dave

    J 1 Reply Last reply
    0
    • D djones1941

      How do I turn on the integer overflow checking to On, so that I can get a System.OverflowException exception thrown. 'Declare FirstNum and SecondNum variables Dim FirstNum, SecondNum As Short Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Assign text box values to variables Try FirstNum = TextBox1.Text SecondNum = TextBox2.Text Catch When Err.Number = 6 'Overflow error MsgBox("Out of calculators peramiters") Catch When Err.Number = 11 'Division by zero error MsgBox("Can't divide by zero") End Try 'Determine checked button and calculate If RadioButton1.Checked = True Then TextBox3.Text = FirstNum + SecondNum End If If RadioButton2.Checked = True Then TextBox3.Text = FirstNum - SecondNum End If If RadioButton3.Checked = True Then TextBox3.Text = FirstNum * SecondNum End If If RadioButton4.Checked = True Then TextBox3.Text = FirstNum / SecondNum End If End Sub End Class Thanks for the Help Dave

      J Offline
      J Offline
      Joshua Quick
      wrote on last edited by
      #2

      djones1941 wrote:

      How do I turn on the integer overflow checking to On, so that I can get a System.OverflowException exception thrown.

      Do the following... 1) Right click on your project in the Solution Explorer. 2) Select Properties. 3) Select "All Configurations" in the Configuration ComboBox in the top left corner. 4) Select ConfigurationProperties\Optimizations in the tree. 5) Uncheck "Remove integer overflow checks".

      D 1 Reply Last reply
      0
      • J Joshua Quick

        djones1941 wrote:

        How do I turn on the integer overflow checking to On, so that I can get a System.OverflowException exception thrown.

        Do the following... 1) Right click on your project in the Solution Explorer. 2) Select Properties. 3) Select "All Configurations" in the Configuration ComboBox in the top left corner. 4) Select ConfigurationProperties\Optimizations in the tree. 5) Uncheck "Remove integer overflow checks".

        D Offline
        D Offline
        djones1941
        wrote on last edited by
        #3

        Thanks that helped alot and now I can finish the project that i was working on. Thanks for the Help Dave

        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