我有一个CSV file
会解析并输入一个Array
这是一个DYNAMIC ARRAY
之后我会得到两个数组之间的区别但是我无法继续在我的计算中因为我的第二个数组无法获得该值。
这是我到目前为止所得到的
Option Explicit
Private Sub cmd_parse_Click()
Dim adata() As String
Dim time1() As String
Dim holder1, holder2
Dim time2() As String
Dim lngIndex As Integer
Dim totaltime() As String
Do Until ft1.AtEndOfStream
On Error Resume Next
a = ft1.ReadLine
b = a
p(0) = a
r = r + 1
Text1.Text = r
z = Left(b, 1)
adata = Split(a, ",")
If Not IsNumeric(z) Then
For i = 0 To UBound(adata)
Text3 = adata(i)
If Text3 <> "Time Stamp" Then
ft2.WriteLine Text3
End If
Next
Else
If holder1 = "" Then
time1 = Split(a, ",")
For lngIndex = 0 To UBound(time1)
holder1 = time1(lngIndex)
Next lngIndex
Else
time2 = Split(a, ",")
For lngIndex = 0 To UBound(time2)
holder2 = time2(lngIndex)
Next lngIndex
End If
'subtract array time1 from time2
If holder1 <> "" And holder2 <> "" Then
For lngIndex = 0 To UBound(time2)
holder3 = time2(lngIndex) - time1(lngIndex)
Next lngIndex
End If
End If
DoEvents
Loop
请有人帮助我。
答案 0 :(得分:1)
你还没有完全宣布数组time1和time2以及总时间......
通过使用empty()声明它们,程序还不知道数组的大小......数组adata()的大小是split()函数,但其他数组不是
查看redim
您可能希望time1与adata的大小相同?:
ReDim time1(UBound(adata)) As String