检测报告结论:VB文件写入的问题

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 03:59:35
vb中怎么在特定的一行写入数据?
比如现在有txt文件,第一行是1,第2行是2,第3行是3。。。。第10行是10,现在我要把第3行改为5,怎么修改?

全部读入,到变量里,修改后,再保存.

'用一个比较笨的方法程序如下:

myfile="c:\xxx.txt"'是你的txt文件地址,呵呵自己改
dim temstr,str1 as string
open myfile for input as #1
for i=1 to 10
line input #1,temstr
if i=3 then temstr="5"
str1=str1 & temstr & vbcrlf
next i
close #1
open myfile for output as #2
print #2,str1
close #2

'ok 问题解决