0
我有2個子接口,都接收數組作爲參數。一個工作正常,另一個給出:編譯錯誤:類型不匹配:數組或預期的用戶定義類型。 在下面的代碼中,「InitializeArray」起作用,「PresentTotalRow」不起作用。 任何人都可以找出原因嗎?VBA子調用給出「編譯錯誤:類型不匹配:數組或預期的用戶定義類型」
Sub PresentTotalRow(nCells As Integer, totalProductsPerDay() As Integer)
row = nCells + MatrixRowOffset + 2
Range(Cells(row, 2), Cells(row, 8)) = totalProductsPerDay
End Sub
Sub InitializeArray(ByRef arr() As Long)
Dim N As Long
For N = LBound(arr) To UBound(arr)
arr(N) = 0
Next N
End Sub
Sub ReadTxtFile()
.....
Dim totalProductsPerDay(0 To 6) As Long
InitializeArray totalProductsPerDay
Dim filePath As String
filePath = "C:\work\Documents\input.txt"
Dim oFS As TextStream
If oFSO.FileExists(filePath) Then
Set oFS = oFSO.OpenTextFile(filePath)
......
i = 1
Do While Not oFS.AtEndOfStream
line = oFS.ReadLine
....
nCells = calcNCells
totalProductsCounter = GetTotalProductsCounter()
totalProductsPerDay(Day) = totalProductsPerDay(Day) + totalProductsCounter
i = i + 1
Loop
PresentTotalRow nCells, totalProductsPerDay
oFS.Close
Else
MsgBox "The file path is invalid.", vbCritical, vbNullString
Exit Sub
End If
Exit Sub
End Sub
感謝, 李
感謝。我多麼愚蠢。錯誤消息讓我困惑,我以爲數組不被識別爲數組... – user429400