Private Sub Command1_Click()
Dim x() As String, y() As String, b() As Byte, temp() As String, i As Integer, j As Integer
Open "c:\xx.txt" For Binary As #1
ReDim b(LOF(1))
Get #1, , b
Close #1
x = Split(StrConv(b, vbUnicode), vbCrLf)
Erase b
ReDim y(UBound(x), 13)
For i = 0 To UBound(x)
temp = Split(x(i), " ")
If UBound(temp) = 1 Then
Exit For
Else
For j = 0 To UBound(temp)
y(i, j) = temp(j)
Next
MsgBox Join(temp, vbCrLf), 0, y(i, 0)
End If
Next
End Sub
public type Mydata
Element1 as string
...............
Element13 as string
end type
public function GetAllElement(byval strLine as string,optional SplitChar=space(1)) as mydata
dim AllElement
AllElement=split(strline,splitchar)
with GetAllElement
.Element1=AllElement(0)
........
end with
end function
public function ReadFileLine(ByVal strFile As String,byval lngLineNo as long) as string
dim strContent as string
dim ALLLine
strcontent=ReadFileAsString(strfile)
allline=split(strcontent,vbcrlf)
ReadFileLine=allline(lnglineno-1)
end function
Public Function ReadFileAsByte(ByVal strFile As String, ByRef FileByte() As Byte) As Long
Dim hFile As Long
Dim lngFileSize As Long
Dim bRead As Long
Dim TmpPos As Long
Dim Sum As Long
Dim dwBytesRead As Long
Dim pBuffer(64511) As Byte
'If FileExist(strFile) = False Then Exit Function
hFile = CreateFile(strFile, GENERIC_READ, FILE_SHARE_READ, 0&, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0&)
If hFile = INVALID_HANDLE_VALUE Then Exit Function
lngFileSize = GetFileSize(hFile, 0&)
If lngFileSize <= 0 Then Exit Function
ReDim FileByte(lngFileSize) As Byte
Sum = 0
Do
DoEvents: DoEvents: DoEvents
bRead = ReadFile(hFile, pBuffer(0), 64511, dwBytesRead, 0&)
TmpPos = VarPtr(FileByte(0)) + Sum
CopyMemory ByVal TmpPos, ByVal VarPtr(pBuffer(0)), ByVal dwBytesRead
Sum = Sum + dwBytesRead
DoEvents: DoEvents: DoEvents
Loop Until Sum >= lngFileSize
ReadFileAsByte = lngFileSize
CloseHandle hFile
End Function
Public Function ReadFileAsString(ByVal strFile As String) As String
Dim FileByte() As Byte
ReadFileAsByte strFile, FileByte()
ReadFileAsString = StrConv(FileByte(), vbUnicode) 'Byte2String