0

我在使用以下代码行时遇到问题。

'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...

makeDate 函数基本上是

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

试图输出变量 Prev_date 或 Next_date 是行不通的!但是,将循环上限( UBound(Payment_pay ) 交换为例如 6,将给出预期的返回值(正确的日期......)。循环迭代器“i”似乎有问题。

非常感谢您的帮助!

提前致谢, 尼克拉斯

4

1 回答 1

0

试试这个

For i = 1 To UBound(Payment_pay)
 Prev_date = makeDate(format(i - payFreq_pay) & "M")
 Next_date = makeDate(format(i) & "M")
Next i
于 2013-05-15T10:41:31.713 回答