注册 登录
编程论坛 VB6论坛

新人求助,请各位来帮帮忙!

qq6109960 发布于 2013-04-10 12:45, 391 次点击
我想弄个读取文件并操作里面的内容的程序,请大家帮个忙,内容是打开d:\1.txt(1.txt里面的内容是aaabbbccc),我现在要将1.txt里面的内容变成(aaabbbddd),请高手们帮帮忙!!!
2 回复
#2
Artless2013-04-10 13:15
用记事本更简单
#3
xbj_hyml2013-04-10 15:44
Private Sub Command1_Click()
    Dim i As Integer, num As Integer
    Dim filePath As String
    Dim strTemp As String, str1 As String

    i = FreeFile
    filePath = "d:\1.txt"
    '将内容读取到strTemp="aaabbbddd",这里只针对你所说的情况,如果其它复杂一点的,你就要好好研究下读写文件了
    Open filePath For Input As #i
    Do While Not EOF(i)
        Input #i, strTemp
        str1 = str1 & strTemp
    Loop
    Close #i
    'str1转换
    str1 = Replace$(str1, "d", "c")
    i = FreeFile
    '保存到 txt 中
    Open filePath For Output As #i
    Print #i, str1
    Close #i
End Sub
1