Solved

Try Catch Assistance

Posted on 2014-03-10
5
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

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…
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…
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.

688 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