Have nice Evening!
I have an error message of "Overflow Exception was Unhanded by User code"when i am trying to exceute below very simple code.

Partial Class zeesant
    Inherits System.Web.UI.Page
    Dim x As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        x = (Val(TextBox1.Text) * (Val(TextBox2.Text) / Val(TextBox3.Text))) + Val(TextBox4.Text) * Val(TextBox5.Text)

    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Textbox6.Text = x

    End Sub
End Class

I hope somebody have solution of my problem.!!

Check if there is divide by zero because TextBox3.Text is blank or 0.

Write you if upfront for that.

In addition, simple int might not be large enough, but that doesn't seem to be the current error.

please mark thread closed if this helps. Otherwise post your solution if any.

Edited 6 Years Ago by padtes: n/a

You also have the calculation being performed in the Page_Load event. Unless you have defined default values within those textbox controls, you're going to get an exception when you first load the page (prior to postback). If there are no default values, move the calculation to the button_click event handler and, of course, validate the inputs prior to performing the calculation.

You also have the calculation being performed in the Page_Load event. Unless you have defined default values within those textbox controls, you're going to get an exception when you first load the page (prior to postback). If there are no default values, move the calculation to the button_click event handler and, of course, validate the inputs prior to performing the calculation.

oh ya.....I just forgot that I have written caluculation on page_load.
yup,U r correct MR.Apegram.....

This question has already been answered. Start a new discussion instead.