SPENCER YANG您好,先前承蒙您指教關於txt檔轉入Access問題已大致了解,
但是我的txt檔為什麼都找不到換行字元呢?
我的intPosition 都會是0,所以都只可轉入第一筆資料,
這是我改過的部份程式:
Private Sub PutToData1(ByVal strFileName As String, rs As ADODB.Recordset)
Dim strX As String
Dim strY As String
Dim intPosition As Integer
Dim intPlus As Integer
Line Input #1, strX
While Len(strX) > 0
intPosition = InStr(strX, vbLf)
If intPosition > 0 Then
strY = Left(strX, intPosition - 1)
strX = Mid(strX, intPosition + 1)
Else
strY = strX
strX = ""
End If
With rs
.AddNew
!OsxFileNo = Left(strY, 6)
!OsxRecordNo = Mid(strY, 7, 6)
!OsxRecordType = Mid(strY, 13, 4)
!OsxData = Mid(strY, 17, 130)
.Update
End With
Wend
End Sub
這是我的txt檔:
000343000001AA W1130210003A000016801SBRN26155544 0105AIR .01255 12 20000503200005252000052520000503200005260470
000343000002AB W113021B AJBI INCORPORATED S AJBI INCORPORATED S ECANTON, MA 02021
000343000003AB W113021DSAORIENT CONSOLIDATION SERVICES DSEHONG KONG DSFHONG KONG
000343000004AC W1130210000INH 0001BX9980 BUYR0000LAURA KABLIK DRESSSLSM0119BOB BERNSTEIN
000343000005AC W1130210000NOTE0001SOFT KICKS PATT0000TS2170ZW CONS0000NEW SNSATION W NEW SNSATION W
000343000006AC W1130210000MAT LAMY SUEDE 我的txt檔用記事本看是非常整齊的一行接著一行排列
請問我的問題在那裡,請您再幫幫我,
謝謝!