{求助}怎样读取指定行数文本并放进数组
有一个只有一列的文本文件,约有三百行左右。要求每次读取20行数字,对应放进一个数组中。然后读取下二十行。
小弟新手。。谢谢各位大侠指点。。
祝大家身体健康,父母长命百岁。。。。。。
不是很清楚你20行数字怎么对应处理,你把下面的数据改改看吧
Dim i As Integer
Dim shuzu() As String
Dim blnjudge As Boolean
Open FName For Input As #1
Do While Not EOF(1)
Line Input #1, s0
i = i + 1
s = s + s0 '20个数据对应处理
If i = 20 Then
If blnjudge = False Then
ReDim shuzu(1)
shuzu(1) = s
blnjudge = True
i = 0
Else
ReDim Preserve shuzu(UBound(shuzu) + 1)
shuzu(UBound(shuzu)) = s
i = 0
End If
End If
Loop
If i > 0 Then
ReDim Preserve shuzu(UBound(shuzu) + 1)
shuzu(UBound(shuzu)) = s
End If
Close #1