[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Try Catch Assistance

Posted on 2014-03-10
5
Medium Priority
?
305 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 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

649 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