文件操作:
Dim MyVar
Open "文件名称(包含路径)" For Input As #1 Do While Not EOF(1) Input #1, MyStr
...................
Loop Close 1#
这是一个我写的分离含有不等空格字段程序,可以参考:
Function SplitSpace(MainStr As String, Pos As Integer) As String '分离含有不等空格字段程序 Dim L, i, j, n, k Dim StrVal(0 To 10000) As Variant Dim MyStr As String n = 1: j = 0: i = 0 MyStr = " "
L = Len(MainStr) While i < L k = InStr(n, MainStr, " ") If k = 0 Then k = L + 1 MyStr = Mid(MainStr, n, k - n) n = InStr(n, MainStr, " ")
If MyStr = "" Then n = n + 1 i = i + 1 Else j = j + 1 i = i + Len(MyStr) StrVal(j) = MyStr End If
Wend
SplitSpace = StrVal(Pos) End Function |