VBA IIf frustration

  • Thread starter Thread starter Tinius Olsen
  • Start date Start date
T

Tinius Olsen

Form inputs measurements normally in decimal format, into
table. This form has a button, to input occasional
fractional measurements, into this table.

Used the following, portion of button code, to accomplish
this:
DecVal = IIf(txtDenom = 0, txtInt, txtInt+
(txtNum/txtDenom))
Thought this would take care of those occasions there was
no fractional part.
If measurement is 3 3/16" this works fine and yields
3.1875 as it should, but if measurement is only 3",
rather then looking at the denominator part of the
fraction and seeing the zero letting DecVal equal only the
Integer, it errors out.

If I understand the VBA help this is because IIF always
evaluates both truepart and falsepart, even though it
returns only one of them.

Help how do I get around this ?
 
Back
Top