我在尝试读取文本文件时遇到问题。基本上,文本文件由信息块组成,在每个块之间我有一个空白行。Hier 是我的文本示例:
FESTWERT FRAUS
LANGNAME "bla bla bla"
FUNKTION dfgg
EINHEIT_W "ü"
WERT -9.2654122070312500
END
KENNFELD KFDWNWCSA 4 4
LANGNAME "bla bla bla"
FUNKTION FGHK
EINHEIT_X "8/kl"
EINHEIT_Y "bla"
EINHEIT_W "bla"
ST/X 1658.0000000000000000 987.0000000000000000 3698.0000000000000000 3520.0000000000000000
ST/Y -30.0000000000000000
WERT 22.0000000000000000 16.9870000000000000 10.3210000000000000 10.0000000000000000
ST/Y 0.0000000000000000
WERT 10.0000000000000000 10.0000000000000000 10.0000000000000000 10.0000000000000000
ST/Y 45.2500000000000000
WERT 10.0000000000000000 10.0000000000000000 10.0000000000000000 10.0000000000000000
ST/Y 21.0000000000000000
WERT 22.0000000000000000 16.0000000000000000 10.0000000000000000 10.0000000000000000
END
实际上我想从这些块中提取数字。但我收到此错误:这是我的代码:
Dim fso As New FileSystemObject
Dim ts As TextStream
Set ts = fso.OpenTextFile(Name, ForReading)
Do While Not ts.AtEndOfStream
strArray = Split(ts.ReadLine, Space(1), 2) ' Extrahieren, was in einer Zeile ist
If Len(Join(strArray, "")) <> 0 Then
If strArray(0) = "KENNFELD" Then
SWKNF = True
ts.SkipLine
ts.SkipLine
ts.SkipLine
ts.SkipLine
ts.SkipLine
wertkenfeld = strArray(1)
strArray(1) = ""
End If
If strArray(0) = "END" Then werden
If SWKNFL = True Then
For P = 0 To X - 1
DoCmd.RunSQL ("INSERT INTO Test_DCML_G (XValue,Wert,name) VALUES ('" & Stx(P) & "','" & wert(P) & "','" & wertkenfeld & "');")
Next P
End If
SWKNF = False
SWKNFL = False
Erase Warray
X = 0
W = 0
Erase Yarray
Erase Xarray
Erase Stx
Erase wert
ts.SkipLine ' I get the error in this line
End If
.....
你能帮我解决这个问题吗?太感谢了