|
Option Compare Database
Sub main()
Dim fs, f
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
cnn.Open CurrentProject.Connection
rst.Open "导入文件", cnn, adOpenKeyset, adLockOptimistic
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(CurrentProject.Path + "\导出文件.txt")
Do
para = f.readline
zd1 = Mid(para, 1, 17)
zd2 = Mid(para, 18, 10)
zd3 = Mid(para, 28, 14)
zd4 = Mid(para, 42, 10)
zd5 = Mid(para, 52, 2)
With rst
.AddNew
.Fields(0) = zd1
.Fields(1) = zd2
.Fields(2) = zd3
.Fields(3) = zd4
.Fields(4) = zd5
.Update
End With
Loop Until f.AtEndOfLine
End Sub
|
|