这应该是你需要的:
必要时,缓冲区用于存储预读取行。
'Definition of the buffer
Dim buffer As String
'Now also check if the buffer is filled
Do While (Not objStream.AtEndOfStream) Or (Len(buffer) > 0)
'If the buffer is filled, use and clear it, instead read next line
If Len(buffer) > 0 Then
strLine = buffer
buffer = vbNullString
Else
strLine = objStream.ReadLine
End If
ReDim MyArray(0)
MyArray = Split(strLine, ",")
If MyArray(0)= "N1" Then
rs.AddNew
rs("Field1") = MyArray(0)
rs("Field2") = MyArray(1)
'Read a line to the buffer and check if it starts with 'N2'
buffer = objStream.ReadLine
If buffer Like "N2*" Then
'Use the content of the buffer, store it in Field3 and 4, and clear it
MyArray = Split(buffer, ",")
buffer = vbNullString
rs("Field3") = MyArray(0)
rs("Field4") = MyArray(1)
End If
rs.Update
End If
Loop