我有一个宏,它将读取一个输入文件,一次一个字符。我需要它来找到文件的End Of Line标记。这就是我到目前为止所做的:
While Not EOF(inFileNum)
oneChar = Input(1, #inFileNum)
While (oneChar <> vbLf)
答案 0 :(得分:0)
这样的事情:
Dim handle As Long, ch, sep, i
handle = FreeFile
Open "D:\Stuff\test.csv" For Input As handle
Do While Not EOF(handle)
ch = Input(handle, 1)
If Len(sep) = 0 Then
If ch = vbLf Or ch = vbCr Then sep = ch
Else
'vbCr + vbLf is a valid combination,
' otherwise it should be a single character....
If sep = vbCr And ch = vbLf Then sep = vbCrLf
Exit Do
End If
Loop
Close handle
If Len(sep) > 0 Then Debug.Print "Found line separator:"
For i = 1 To Len(sep)
Debug.Print Asc(Mid(sep, i, 1))
Next i