# How to calculate a formula in an array(index)

#### jerry

##### New member
Thanks in advance for the help.

Am working with parallel arrays. There are math formulas stored in Formula(index) that do calcs on Value1(index) and Value2(index) and then store the result in Answer(index).

Two things usually happen: crash or the formula itself is displayed without evaluation.

I tried several different approaches but here is the current subroutine:

Sub...
Dim index As Integer
Dim L, Q, D As Double
For index = 0 To upperBound
Q = CDbl(Value1(index))
L = CDbl(Value2(index))
'D = (L / 60 * 3) * Q ' Test L & Q in a calc.
D = CDbl(Formula(index)) 'Value2(index)
Next
End Sub

How do I force Formula(index) to calculate?

#### Eric_Mutta

##### Member
What exactly are you storing in Formula(index)? If these are mathematical formulas of some kind, you'll need to build a mini parser and evaluator (which is hard work!). If the formulas are known at compile-time, then there is another solution...

Replies
1
Views
2K
Replies
2
Views
2K
Replies
1
Views
2K
Replies
1
Views
5K
Replies
0
Views
1K