Once again an easy question for you …
In a pushbutton-action-event i want to call a function to calculate a value and to return it back.
My method is called “calculateAmortisationYears” and in the action event i call the method in the folowing way:
intAmortisation = calculateAmortisationYears (dblStartInvestQM, dblQM, dblEinsparungQM, dblInvest, intJahre, dblZinssatz, dblSteigerung)
Yet the variable value of intAmortisation is always equal to 0.
When i step through the code i see that the function-code is never been used …
What am i doing wrong?
Thanks very much for your assistance
To help narrow things down, what’s the code in your ‘calculateAmortisationYears’ method?
the code looks like:
dim dblInvest(50) as Double
dim dblErsparnis(50) as Double
dim dblCashFlow(50) as Double
dim dblBarwert(50) as double
dim dblBarwertKum(50) as Double
dim intAmortisation as integer
dim intX As Integer
dblInvest(0) = dblQM * dblStartInvestQM
dblErsparnis(0) = dblQM * dblEinsparungQM
dblCashFlow(0) = dblErsparnis(0) - dblInvest(0)
dblBarwert(0) = dblCashFlow(0)
dblBarwertKum(0) = dblBarwert(0)
for intX = 1 to 50
if (intX mod intJahre)=0 then
dblInvest(intX) = 0
dblErsparnis(intX) = dblErsparnis(intX-1) * dblSteigerung
dblCashFlow(intX) = dblErsparnis(intX) - dblInvest(intX)
dblBarwert(intX) = dblCashFlow(intX) * ((dblZinssatz)^-(intX))
dblBarwertKum(intX) = dblBarwertKum(intX-1) + dblBarwert(intX)
if dblBarwertKum(0) > 0 then
intAmortisation = 0
for intX = 2 to 50
if dblBarwertKum(intX) > 0 then
if dblBarwertKum(intX-1) < 0 then
intAmortisation = intX
i found my mistake …
When stepping through the code i thought that the function is also stepped through … this seems not to be the case.
So i corrected an error in the function and the result is as it should be.
If you were stepping through the button action event using the “Step” button (the tiny dot in the middle with the arrow curving over it), it will not step into the function.
If you step through the action event using the “Step In” button (the tiny dot in the middle with the arrow pointing down at it), it will step into any function/method called and then you can follow it through that way.
If you step into a method from the action event and want to quickly get back to stepping through the action event, instead of stepping through the entire called method you can click the “Step Out” button (the tiny dot with the arrow pointing up away from it). It will take you back to the line in the action event right after the one that the method was called from.
See page 190/191 in Book 3: Framework (PDF link).