|
'测试数据2行都不到?第二行为26个数据。一般至少上传3行
'这方法应该可行,就是会假死机,不用管它,等ok弹出来就结束了
'还是这样只读一次,因为文件太大
Option Explicit
Dim arr, cnt As Long
Sub test() '有条件读取
If cnt > 0 Then Exit Sub
Call readfile
'你的代码
'
End Sub
Sub rereadfile() '强制读取
cnt = 0
Call readfile
End Sub
Function readfile()
Dim i As Long, j As Long, t, n As Long, s As String, brr
ReDim arr(1 To 2 * 10 ^ 6, 1 To 33) As String
Open ThisWorkbook.Path & "\新建文本文档.txt" For Input As #1
brr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbLf)
Close #1
For i = 0 To UBound(brr)
If InStr(brr(i), vbTab) Then
cnt = cnt + 1: n = 0: t = Split(brr(i), vbTab)
For j = 0 To UBound(t)
If Len(t(j)) > 0 Then n = n + 1: arr(cnt, n) = t(j)
Next
End If
Next
MsgBox "ok!"
End Function |
评分
-
1
查看全部评分
-
|