我在Visual Basic中编写自定义Excel函数。当我运行该函数时,我在行Compile error: Invalid qualifier
上的mondayArray
上收到错误:For index = 0 To mondayArray.Length - 1
。导致此错误的原因是什么?
Function SumHours(monday, tuesday, wednesday, thursday, friday, saturday, sunday)
Dim mondayHours As Integer
Dim mondayArray() As String
Dim splitArray() As String
SumHours = 0
If monday <> "/" Then
mondayArray = Split(monday, " ")
For index = 0 To mondayArray.Length - 1
splitArray = Split(mondayArray(index), "-")
Next
End If
End Function
答案 0 :(得分:4)
.length
不是数组的属性。使用LBound function和UBound function确定数组的范围(下边界和上边界)。
For index = LBound(mondayArray) To UBound(mondayArray)
我相信你混淆了集合中的.length
属性;例如HtmlElementCollection。