Question

I am trying to validate a form which returns the result (stored in a double) as -1.#IND (which I have been informed is infinity minus one?) How can I trap this error?

-- Background info: The form captures data about a real world object (with 100s of parameters), does a calculation which is handled by a service which returns a result via a 'result' object. The calculation service is doing several calculations which are stored as doubles in the object. There are 6 results returned by the service. The results should fall in the range 0-100. I assume that a divide by zero has occurred somewhere in the calculation which results in the condition mentioned but would like to trap this condition to provide a more specific error message.

Note: I do not have access to the calculation service code.

At the moment I just want to test (pseudo code):

If myRating.value = -1.#IND Then
    ReportError("Divide by zero occurred somewhere in the calc")
End if
Était-ce utile?

La solution

Depending on how this is actually represented, you should be able to use Double.IsNaN or Double.IsNegativeInfinity to test for not-a-number and negative infinity representations from Visual Basic.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top