简体   繁体   English

VBA:输入关键字的分隔符

[英]VBA: Delimiters for Input keyword

I'm trying to parse each line of a text file stored in filepath into my string array. 我试图将存储在文件路径中的文本文件的每一行解析为我的字符串数组。 However, it appears that I'm delimited by characters other than the newline character (for example, commas). 但是,看来我用换行符以外的字符(例如,逗号)分隔。 Is there a way of parsing with new line characters exclusively? 有没有一种专门用换行符解析的方法? Thanks in advance for your guidance. 在此先感谢您的指导。

'Open filepath For Input As #1

    Do While Not EOF(1)
        Input #1, script(numlines)
        numlines = numlines + 1
        If numlines = maxlines Then
            maxlines = maxlines + 100
            ReDim script(maxlines)
        End If
    Loop

    ' Close file
    Close #1

The Input # statement is generally used to read data written with the Write # statement. Input #语句通常用于读取用Write #语句写入的数据。 If you just want to read a line of text, you can use Line Input # . 如果您只想阅读一行文本,则可以使用Line Input #

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM