OverFlow Exception in Dot Net

Here we have declared the Input Textbox as int32 and so if we try tying a larger value Number then it specifies an error named Overflow exception – Value was either too large or too Smaller for Int32.

Private Sub CoversionButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CoversionButton.Click
Try Number1 = System.Int32.Parse(InputTextBox.Text) Decimal2 += 12.345 ResultListBox.Items.Add(Decimal2.ToString()) ResultListBox.Items.Add(Decimal2.ToString("0.00"))
Catch ex As FormatException MessageBox.Show("Enter a Valid Number ")
Try Catch ex As OverflowException
MessageBox.Show("Enter a Number from", Int16.MinValue & "to" & Int32.MaxValue)
End Try
End Sub
So now when you run the program you will be getting a message specifying ?Enter a Number from –32768 to 47483647? as shown below.

Apart from Format Exception and Overflow Exception we also have Windows Exception. This Windows Exception can handle any type of system errors including format and overflow exception.

Related Articles

Object Serialisation in dot net

This article provides an overview of the serialization used in Microsoft .NET and the usage of the same.For example, serialization is used to save session state in ASP.NET and to copy objects to the clipboard in Windows Forms. It is also used by remoting to pass objects by value from one application domain to another.

More articles: Dot Net


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: