Page 1 of 1

Need VBA Code to tm1 ti

Posted: Thu Apr 25, 2019 4:45 pm
by manu0521
I have this code in vba macro , need to convert in ti

For i = k To n
If k > incFreq Then
myPmt = myPmt * (1 + incRate)
k = 1
End If
discnt = discnt * (1 + discntRate)
escPV = escPV + myPmt / discnt
k = k + 1
Next


Having issue where it says i =k to n , they assign K again as 1 when its greater than incFreq and that should cause a loop .I am getting an endless loop when did using while becasue of K being reassigned ,

While(K<=noOfMonhts);
if(K>IncrementFrequency);
PaymentAmount=PaymentAmount*(1+EscalationRate);
K=1;
ENDIF;
discnt=discnt*(1+discountRate);
escpv=escpv+(PaymentAmount/discnt);
K=K+1;
END;

Is there something I am missing here while converting .

Re: Need VBA Code to tm1 ti

Posted: Thu Apr 25, 2019 6:01 pm
by Wim Gielis
This would be the literal translation, not looking at the logic or what it does / is supposed to do:

Code: Select all

i = k;
While( i <= n );
   If( k > incFreq );
      myPmt = myPmt * (1 + incRate);
      k = 1;
   EndIf;
   discnt = discnt * (1 + discntRate);
   escPV = escPV + myPmt / discnt;
   k = k + 1;
   i = i + 1:
End;