![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Nov 2005
Posts: 3
OS: WindowsXP
|
I am taking a VB class and have not done any programming and need some help. I need to know how to write the code to allow a user to continue with the program when a system overflow exception error occurs while maintaining a variable type of short.
|
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) | |
|
Registered User
Join Date: Nov 2005
Posts: 3
OS: WindowsXP
|
Quote:
Not sure if this is enough info or not but here is one section for example: If RadioButton1.Checked = True Then Try TextBox3.Text = FirstNum + SecondNum Catch ex As Exception MsgBox("Number to large and resulted in overflow. Please enter a smaller number.") End Try Else TextBox3.Text = FirstNum + SecondNum End If |
|
|
|
|
|
|
#3 (permalink) | |
|
Tech Hardware Team
Join Date: Jul 2005
Posts: 1,462
OS: Windows
|
Quote:
You can use it as a general error trap and report the status of the error that occured... Catch ex As Exception MsgBox("Error: " & ex.Message) If you only want to catch a particular error then you must use an explicit test... Catch ex As OverflowException MsgBox("Number to large and resulted in overflow. Please enter a smaller number.") As a good programming practice you should add comments, (and it helps get a better grade in school). 'assign a default value and initialize variables and diplayed outputs with default value DefaultNum = 0 SumNum = DefaultNum TextBox3.Text = SumNum If RadioButton1.Checked = True Then Try SumNum = FirstNum + SecondNum Catch ex As OverflowException MsgBox("Number to large and resulted in overflow. Please enter a smaller number.") Catch ex As Exception MsgBox("Error: " & ex.Message) 'some other error occurred Finally TextBox3.Text = SumNum 'assign result SumNum = DefaultNum 'reset in case used elsewhere End Try End If
__________________
|
|
|
|
|
![]() |
| Thread Tools | |
|
|