![]() |
#2
风吹过b2017-11-10 17:37
|

Open filename For Input As #1
Do Until EOF(1)
Line Input #1, txt
If txt <> "" Then
ReDim Preserve sz(ws, 0 To hs) As String
sz(ws, hs) = txt
hs = hs + 1
If hs >= 10000000 Then Stop: hs = 0: ws = ws + 1
End If
Loop
Close #1
Do Until EOF(1)
Line Input #1, txt
If txt <> "" Then
ReDim Preserve sz(ws, 0 To hs) As String
sz(ws, hs) = txt
hs = hs + 1
If hs >= 10000000 Then Stop: hs = 0: ws = ws + 1
End If
Loop
Close #1
这里的数量大于1000万就会出错,用第二种方案

ReDim Preserve sz(5, 0 To hs) As String
'读取文件内容
Open filename For Input As #1
Do Until EOF(1)
Line Input #1, txt
If txt <> "" Then
ReDim Preserve sz(5, 0 To hs) As String
sz(ws, hs) = txt
hs = hs + 1
If hs >= 10000000 Then Stop: hs = 0: ws = ws + 1
hs = hs + 1
End If
Loop
Close #1
'读取文件内容
Open filename For Input As #1
Do Until EOF(1)
Line Input #1, txt
If txt <> "" Then
ReDim Preserve sz(5, 0 To hs) As String
sz(ws, hs) = txt
hs = hs + 1
If hs >= 10000000 Then Stop: hs = 0: ws = ws + 1
hs = hs + 1
End If
Loop
Close #1
但是这里的redim 会把6组的下限都改成一样的,怎么破