?
Solved

Try Catch Assistance

Posted on 2014-03-10
5
Medium Priority
?
310 Views
Last Modified: 2014-03-10
I know that i cannot divide by zero. But i thought that the try catch would take care of this. Why am i getting this error?
Screen Shot
0
Comment
Question by:Basicfarmer
  • 3
5 Comments
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 39919555
Sorry please ignore this comment.
0
 
LVL 7

Expert Comment

by:Kishan Zunjare
ID: 39919583
I still wondered why you are getting error at that point, if catch block is used then if any occurs any where the control has to go in catch block..

I tried bellow code but it works for me..

Dim d As Decimal = 0
        Dim rrr As Decimal = 0
        Dim k As Decimal = 0

        Try
            d = rrr / GetIntVal(k)
            d = (k - rrr) / k
        Catch
        End Try

Open in new window


May be you can use specific exception as bellow;

Catch exc As DivideByZeroException
0
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 39919606
On the main menu click on the Debug -> Exceptions... and in the new window that opens click on the + sign next to Common Language RunTime Exceptions. Now click on the + sign next to System. Now find the exception System.DivideByZeroException and if there is a check mark in the CheckBox to the right click on it to remove it. Then click on the OK button on the lower right side of the window. This is the only thing I know that Will cause that behavior.
0
 

Author Closing Comment

by:Basicfarmer
ID: 39919613
That got it. Thrown was checked on Common Language Runtime Exceptions. So everything under it was checked. I unchecked it there and now i am not throwing the exception any more. But do i need to worry about this being an error once I compile my application?
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 39919637
Those exceptions are for the IDE environment only. If you were to take out the Try/Catch block you will see that it will throw the exception because it is not being caught by the Catch block.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question