Error trap for a divide by zero error

S

SharonInGa

I need to show a blank in my calculation field instead of #Div/0! when one of
my numbers is a zero. The code below was given to me and I do not
undertand it. Please explain how to do this in Novice level, please!

2/10 = .4
2/0 = #Div/0


Dim x,y,z
x=10
y=0
z=0
On error resume next
 
D

Dirk Goldgar

SharonInGa said:
I need to show a blank in my calculation field instead of #Div/0!
when one of my numbers is a zero. The code below was given to me
and I do not undertand it. Please explain how to do this in Novice
level, please!

2/10 = .4
2/0 = #Div/0


Dim x,y,z
x=10
y=0
z=0
On error resume next

Um, that's not code in any meaningful sense, so it's no wonder you
didn't understand it. Was there more to it?

Are you doing this calculation in the controlsource of a control on a
form? If so, I would think you could use something like this:

=IIf([txtDenominator]=0, Null, [txtNumerator]/[txtDenominator)

, where you would substitute your own field or control names for
"txtNumerator" and "txtDenominator".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top