DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Variables for use in FormulaCalc

It seems that I can't use an auxiliary variable (L4 for example) in a For...Next loop. However, when I try to use a user defined variable then I can't get the FormulaCalc function to recognise it. Thus, neither of the following two blocks of code seem to work:
 
L1 = 11
For L4 = L1-1 to (L1-2)*2
Call FormulaCalc("Ch(L4) = -Ch(L4)")
Next
 
L1 = 11
For ChnCount = L1-1 to (L1-2)*2
Call FormulaCalc("Ch(ChnCount):=-Ch(ChnCount)")
Next
 
but as a workaround the following block of code does seem to work:
 
L1 = 11
For ChnCount = L1-1 to (L1-2)*2
L4 = ChnCount
Call FormulaCalc("Ch(L4):=-Ch(L4)")
Next
 
but this seems lengthy and messy. Is there a more appropriate way?
 
Thanks, Si.
 
0 Kudos
Message 1 of 3
(3,533 Views)
Hi Si,
As you already noticed you can't use Auxiliary variables in VBS For...Next loops. To avaid copying the value from ChnCount to L4 you could use a While Statement, like the following:

L1 = 11
L4 = L1 - 1
While L4 <= (L1-2)*2
Call FormulaCalc("Ch(L4):=Ch(L4)")
L4 = L4 + 1
Wend

Hope that helps,
Ralf
0 Kudos
Message 2 of 3
(3,524 Views)

Many thanks Ralf.

Si.

 

0 Kudos
Message 3 of 3
(3,519 Views)