Solved

Try Catch Assistance

Posted on 2014-03-10
5
300 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 63

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 63

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 63

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

820 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