Dim strFileString As String
Dim lFileLen1 As Long
Dim strFile as string
strFile="C:\big.txt"
lFileLen1 = FileLen(strFile) //7168226
Open strFile For Input As #1
Input #1, strFileString
Close #1
lFileLen1 = Len(strFileString) //只能读出5858740
'返回以行数组表示的文本文件内容。tStrings()的每个元素是文本的一行。默认间隔符号是换行。
Dim tStrings() As String
tStrings()=StringsByFile(tFileName)
如果你的每个记录是以"?"间隔,则这样读:
Dim tStrings() As String
tStrings()=StringsByFile(tFileName,"?")
'返回以String表示的文本文件内容(包括换行符)。tText包含了文本当中所有内容(含换行符号)
Dim tText As String
tText=TextGetByFile(tFileName)
下面的函数有依存关系,必须同时存在。
Public Function StringsByFile(ByVal tFileName As String, Optional ByVal pDelimiter As String = vbCrLf) As String()
Dim tOutStrings() As String
Dim tText As String
tText = TextGetByFile(tFileName)
tOutStrings() = Split(tText, pDelimiter)
StringsByFile = tOutStrings()
End Function
Public Function TextGetByFile(ByVal tFileName As String) As String
Dim tOutText As String
Dim tBytes() As Byte
tBytes() = BytesGetByFile(tFileName)
tOutText = StrConv(tBytes(), vbUnicode)
TextGetByFile = tOutText
End Function