Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想得到一个字符串到换行符。为此,我尝试使用 InStr(text, vbCrLf),但该函数返回 0。MsgBox 显示考虑到行跳转的文本。为什么返回0?
'VBA
InStr(text, "/r") ' returns 0 InStr(text, "/n") ' returns 0 InStr(text, vbCrLf) ' returns 0
感谢@Mathieu Guindon 注意到 OP 正在寻找错误的字符。
我正在查看您的 '\n' 并跳转到我喜欢使用的替代方案,即 Chr 代码
InStr(text, chr$(10))
引用:
ASCII 字符代码 10 有时写为 \n,有时称为换行或 NL。ASCII 字符 10 也称为换行或 LF