Error trap for a divide by zero error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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".
 
Back
Top