我已经阅读了Stackoverflow上的示例,但仍然无法正确地说出这一说法 - 有人能指出我出错的地方吗?
在我尝试将LineText
中保存的文本行拆分为多维数组Orders()
时,错误是类型不匹配。我尝试从RawOrders(j)
到Orders(y, x)
但结果相同。
Dim RawOrders() As String
Dim Orders() As String
Dim LineText As String
Dim h As Integer
Dim p As Integer
Dim x As Integer
Dim y As Integer
Dim j As Integer
Dim FilePath As String
Dim FileName As String
Dim FileNum As Integer
FileNum = FreeFile()
Open FileName For Input As #FileNum
RawOrders = Split(Input$(LOF(FileNum), #FileNum), vbNewLine)
Close #FileNum
ReDim Orders(3, 21)
h = 1
p = 0
j = 0
x = 0
y = 0
Do While Not RawOrders(p) = ""
LineText = RawOrders(h)
Do While j <> 21
Orders(y, x) = Split(LineText, ",") *Errors out here giving Type MissMatch*
x = x + 1
j = j + 1
Loop
y = y + 1
h = h + 1
p = p + 1
Loop
答案 0 :(得分:0)
Dim splitRes() as Variant 'one dimension
Dim orders()
splitRes = yoursplitfunction
ReDim Orders(3, 21)
Do While j <> 21
Orders(y, x) = splitRes(j) 'guessing that you have 21 values in your lineText
'if you have less you get an error
x = x + 1
j = j + 1
Loop
答案 1 :(得分:0)
这是我将unresolved external error
更改为变体后所得到的。
Orders()