excel - 查找输入文件的行尾标记
问题描述
我有一个宏可以读取输入文件,一次一个字符。我需要它来找到文件的行尾标记。这是我到目前为止所拥有的:
While Not EOF(inFileNum)
oneChar = Input(1, #inFileNum)
While (oneChar <> vbLf)
解决方案
像这样的东西:
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
推荐阅读
- vb.net - '无法将'System.Int32[*]'类型的对象转换为'System.Int32[]'类型。'
- scikit-learn - sklearn 集群标签的格式是什么?
- android - Unity3D - 无法构建 64 位 Android
- python - isvisible() 缺少 1 个必需的位置参数:'self' Python Turtle 图形错误
- python - 将 pandas 数据框列映射到数组
- prolog - Prolog 逻辑编程 二叉树谓词
- android - 可连续绘制多个可绘制对象
- ruby-on-rails - Rails 集成测试:我的测试向控制器发布了一个新条目,如何检索该条目?
- linux - 为什么我不能使用 xterm 直接查看来自模块的日志信息,而是通过日志文件?
- postgresql - Postgres 跨多列的全文搜索索引