【问题标题】:Edit text file line by line VB6逐行编辑文本文件 VB6
【发布时间】:2017-04-19 18:42:07
【问题描述】:

我在此页面中使用此代码,用于逐行读取数据。现在如何逐行编辑文本文件?

(VB6) Reading text files line by line looking for specific words

    If InStr(1, lines(i), "sample text", vbTextCompare) Then
    lines (i)= "new text"

我使用了这段代码,但没有任何改变。

【问题讨论】:

    标签: file vb6 edit


    【解决方案1】:

    我认为,您正在编辑字符串数组,而不是文本文件本身。 您需要将更新后的字符串数组保存到文本文件中。

    Dim i as Integer
    Dim myFile as Integer
    myFile = FreeFile
    Open "C:\MyTextFileFromStringArray.txt" For Output As #myFile
    For i = 0 To UBound(lines)
        Print #myFile, lines(i)
    Next i
    Close #myFile
    

    【讨论】:

    • 我只想编辑一个特殊的行,其他数据不会改变
    猜你喜欢
    • 2019-12-31
    • 1970-01-01
    • 2011-05-22
    • 1970-01-01
    • 2019-09-02
    • 1970-01-01
    • 1970-01-01
    • 2016-06-29
    • 1970-01-01
    相关资源
    最近更新 更多