Hi everyone,
Forgive me if this question has been asked before or direct me to the thread. I'm working on a bit of code that has to deal with DIV/0 (see below). In VB I used "On Error Resume Next" but here and VB.net, the DIV/0 actually returns NaN which doesn't act like 0 when used in mathematical formulas.
What I need to know is how to convert NaN as a result of dividing by 0 to make it equal 0. Here's my example. If I use fuel model 1 in the equation, I need f_i2 to equal 0 not NaN because's it's used later to get F which is used later to add to something which is used later to create another variable, etc. This is a scaled down example of a formula that's over 300 lines long and there's 40 fuel models to chose from and they are supposedly to coming out with more next year.
In other words, How can I get a value for F even if a,b,c,d,e happens to be 0. Each model has a least one 0 for a variable. It's unavoidable. Any help would be greatly appreciated. Thanks in advance.
Fuel Model 1
a= 2.9
b= 0.41
c= 0.15
d= 0
e= 0
Fuel Model 5
a= 3
b= 0
c= 0
d= 2.6
e= 1.3
OnehrSurfacefVolRatio = 2500
TenhrSurfacefVolRatio = 109
HundhrSurfacefVolRatio = 30
LvHerbSurfaceVolRatio = 1500
LvWoodySurfaceVolRatio = 1500
OnehrFuelLoad = a
TenhrFuelLoad = b
HundhrFuelLoad = c
LvHerbFuelLoad = d
LvWoodyFuelLoad = e
A_i1j1 = ((OnehrSurfacefVolRatio * OnehrFuelLoad) / 32)
A_i1j2 = (TenhrSurfacefVolRatio * TenhrFuelLoad) / 32
A_i1j3 = (HundhrSurfacefVolRatio * HundhrFuelLoad) / 32
A_i2j1 = (LvHerbSurfaceVolRatio * LvHerbFuelLoad) / 32
A_i2j2 = (LvWoodySurfaceVolRatio * LvWoodyFuelLoad) / 32
A_i1 = A_i1j1 + A_i1j2 + A_i1j3
A_i2 = A_i2j1 + A_i2j2
A_T = A_i1 + A_i2
f_i1j1 = A_i1j1 / A_i1
f_i1j2 = A_i1j2 / A_i1
f_i1j3 = A_i1j3 / A_i1
f_i2j1 = A_i2j1 / A_i2
f_i2j2 = A_i2j2 / A_i2
f_i1 = f_i1j1 + f_i1j2 + f_i1j3
f_i2 = f_i2j1 + f_i2j2
F= (500 * f_i1) + (800 * f_i2)
Msgbox (F,"Value for F")
Reggie
Forgive me if this question has been asked before or direct me to the thread. I'm working on a bit of code that has to deal with DIV/0 (see below). In VB I used "On Error Resume Next" but here and VB.net, the DIV/0 actually returns NaN which doesn't act like 0 when used in mathematical formulas.
What I need to know is how to convert NaN as a result of dividing by 0 to make it equal 0. Here's my example. If I use fuel model 1 in the equation, I need f_i2 to equal 0 not NaN because's it's used later to get F which is used later to add to something which is used later to create another variable, etc. This is a scaled down example of a formula that's over 300 lines long and there's 40 fuel models to chose from and they are supposedly to coming out with more next year.
In other words, How can I get a value for F even if a,b,c,d,e happens to be 0. Each model has a least one 0 for a variable. It's unavoidable. Any help would be greatly appreciated. Thanks in advance.
Fuel Model 1
a= 2.9
b= 0.41
c= 0.15
d= 0
e= 0
Fuel Model 5
a= 3
b= 0
c= 0
d= 2.6
e= 1.3
OnehrSurfacefVolRatio = 2500
TenhrSurfacefVolRatio = 109
HundhrSurfacefVolRatio = 30
LvHerbSurfaceVolRatio = 1500
LvWoodySurfaceVolRatio = 1500
OnehrFuelLoad = a
TenhrFuelLoad = b
HundhrFuelLoad = c
LvHerbFuelLoad = d
LvWoodyFuelLoad = e
A_i1j1 = ((OnehrSurfacefVolRatio * OnehrFuelLoad) / 32)
A_i1j2 = (TenhrSurfacefVolRatio * TenhrFuelLoad) / 32
A_i1j3 = (HundhrSurfacefVolRatio * HundhrFuelLoad) / 32
A_i2j1 = (LvHerbSurfaceVolRatio * LvHerbFuelLoad) / 32
A_i2j2 = (LvWoodySurfaceVolRatio * LvWoodyFuelLoad) / 32
A_i1 = A_i1j1 + A_i1j2 + A_i1j3
A_i2 = A_i2j1 + A_i2j2
A_T = A_i1 + A_i2
f_i1j1 = A_i1j1 / A_i1
f_i1j2 = A_i1j2 / A_i1
f_i1j3 = A_i1j3 / A_i1
f_i2j1 = A_i2j1 / A_i2
f_i2j2 = A_i2j2 / A_i2
f_i1 = f_i1j1 + f_i1j2 + f_i1j3
f_i2 = f_i2j1 + f_i2j2
F= (500 * f_i1) + (800 * f_i2)
Msgbox (F,"Value for F")
Reggie