문제

I am having trouble with the following line of code.

'payFreq is input of type "Long"
Dim DF As Variant
'discFact here is input of type "Range"
DF = discFact.Value

Dim Payment_pay() As Double
ReDim Payment_pay(1 To UBound(DF))

Dim i As Long
'Fill with zeros
For i = 1 To UBound(Payment_pay)
 Payment_pay(i) = 0
Next i

Dim Prev_date As Date
Dim Next_date As Date

For i = 1 To UBound(Payment_pay)
 Prev_date = makeDate((i - payFreq_pay) & "M")
 Next_date = makeDate(i & "M")
Next i

'Continuation of code...

The makeDate function is basically

Function makeDate(Term As String) As Date
 ...
End Function

Trying to output the variable Prev_date or Next_date won't work! However, interchanging the upper loop bound ( UBound(Payment_pay ) to e.g. 6, will give the expected return value (a correct date...). It seems something is wrong with the looping iterator "i".

Help is much appreciated!

Thanks in advance, Niklas

도움이 되었습니까?

해결책

Try this

For i = 1 To UBound(Payment_pay)
 Prev_date = makeDate(format(i - payFreq_pay) & "M")
 Next_date = makeDate(format(i) & "M")
Next i
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top