1
我只是有一個字符串數組類似的問題,現在這是工作,但沒有。我試着返回一個Integer數組作爲Integer()類型和Variant()並循環並用Cint()轉換每個元素。我得到一種類型不匹配的方式。下面是代碼:無法返回Excel中的整數數組VBA
Dim pathTimeList() As Integer
ReDim pathTimeList(0 To stepCount)
pathTimeList = set_path_time_list(stepCount)
下面是函數代碼:
Private Function set_path_time_list(ByVal stepCount As Integer) As Integer
Dim pathTimeList() As Integer
ReDim pathTimeList(0 To stepCount - 1)
Dim loopIndex As Integer
loopIndex = 0
Dim firstRow As Integer
Dim lastRow As Integer
Dim firstColumn As Integer
Dim lastColumn As Integer
firstRow = 3
lastRow = 27
firstColumn = 2
lastColumn = 2
For i = firstRow To lastRow
For j = firstColumn To lastColumn
pathTimeList(loopIndex) = Cells(i, j).Value
Next j
loopIndex = loopIndex + 1
Next i
set_path_time = pathTimeList
End Function
我沒有得到類型不匹配。請指出代碼在哪一行失敗。 – Vegard