Solved

Try Catch Assistance

Posted on 2014-03-10
5
296 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 62

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 62

Accepted Solution

by:
Fernando Soto earned 500 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 62

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now