gpt4 book ai didi

vba - Visual Basic - 编译错误 : Invalid qualifier

转载 作者:行者123 更新时间:2023-12-04 02:19:03 25 4
gpt4 key购买 nike

我正在用 Visual Basic 编写自定义 Excel 函数。当我运行函数时,出现错误: Compile error: Invalid qualifier on mondayArray on the line 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

最佳答案

.length 不是数组的属性。使用 LBound functionUBound function确定数组的范围(下边界和上边界)。

        For index = LBound(mondayArray) To UBound(mondayArray)

我相信您混淆了集合中的 .length 属性;例如HtmlElementCollection.

关于vba - Visual Basic - 编译错误 : Invalid qualifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32390296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com