|
以下是引用zhuyiwen在2004-4-30 12:16:38的发言:
这段代码,你试试:
Public Sub Turn(ByVal Filename As String)
Dim intFileNo As Integer
Dim BLOB() As Byte
Dim lngFile As Long
Dim i As Long
intFileNo = FreeFile
Open Filename For Binary As intFileNo
lngFile = LOF(intFileNo)
ReDim BLOB(lngFile)
Get intFileNo, , BLOB
Close intFileNo
For i = 0 To lngFile - 1
If BLOB(i) < 32 And BLOB(i) <> 10 Then BLOB(i) = 32
Next
intFileNo = FreeFile
Open Filename & "-n.txt" For Binary As intFileNo
Put intFileNo, , BLOB
Close intFileNo
Dim ss As String
Dim kk
Dim jj, dd
Open Filename & "-n.txt" For Input As intFileNo
Line Input #1, ss
Close intFileNo
kk = Split(ss, Chr(10))
lngFile = UBound(kk)
Dim rs As New ADODB.Recordset
rs.Open "[表2]", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs.AddNew
For i = 0 To lngFile - 1
ss = "": dd = ""
kk(i) = LTrim(kk(i))
If kk(i) <> "" Then
If InStr(1, kk(i), " ") > 0 Then ss = Left(kk(i), InStr(1, kk(i), " ") - 1)
dd = LTrim(Mid(kk(i), Len(ss) + 5))
If InStr(1, dd, " ") > 0 Then dd = Left(dd, InStr(1, dd, " ") - 1)
Select Case ss
Case "Date": rs("Date") = dd & " "
Case "Operator": rs("OperatorID") = dd & " "
Case "atient": rs("atientID") = dd & " "
Case "Type": rs("Type") = dd & " "
Case "Temp": rs("Temp") = dd & " "
Case "tHb": rs("tHb") = dd & " "
Case "FIO2": rs("FIO2") = dd & " "
Case "pH(T)": rs("pH") = dd & " "
Case "pCO2(T)": rs("pCO2") = dd & " "
Case "pO2(T)": rs("pO2") = dd & " "
Case "HCO3-": rs("HCO3-") = dd & " "
Case "SBC": rs("SBC") = dd & " "
Case "ABE": rs("ABE") = dd & " "
Case "SBE": rs("SBE") = dd & " "
Case "tCO2": rs("tCO2") = dd & " "
Case "sO2": rs("sO2") = dd & " "
End Select
End If
Next
rs.Update
rs.Close
Set rs = Nothing
End Sub
==============
例如:
Call Turn(currentproject.Path & "\rec01.txt")
祝你好运!
这段代码已经运用,但是没有全部看懂意思,查阅了帮助,还是不太明白,请各位帮助注译一下,谢谢。 |
|