例如: Private Sub Command1_Click()
Open "e:\vb6.0.txt" For Append As #1
Write #1, Text1.Text, Text2.Text
Close #1
End Sub
按下Command控件时text1,text2内容存入 vb6.0.txt 文本文件中. (帮我解决下面2个问题) 1:我想修改vb6.0文本文件中的某个记录 (例如我要将vb6.0中的 "0308008151","李明"修改为"0308008150","李明")
2:我想将 "0308008151","李明"这个记录删除
Open "e:\vb6.0.txt" For Append As #1
Write #1, Text1.Text, Text2.Text
Close #1
End Sub
按下Command控件时text1,text2内容存入 vb6.0.txt 文本文件中. (帮我解决下面2个问题) 1:我想修改vb6.0文本文件中的某个记录 (例如我要将vb6.0中的 "0308008151","李明"修改为"0308008150","李明")
2:我想将 "0308008151","李明"这个记录删除
还要用追加方式?为何不用PUT方式写入数据呢?为何不用数据库呢?用数据库要好多了。
dim Data() as byte
dim filesize as long
dim str as string
filesize=filelen("d:\vb6.0.txt")
redim data(filesize) as byte
open "d:\vb6.0.txt" for binary as #1
get #1,filesize,data
close #1
str=strconv(data,vbunicode)
str=replace(str,"0308008151","0308008150")
open "d:\vb6.0.txt" for output as #1
print #1,str
close #1
---------------------
1.可以用ADO+SQL操作文本格式记录集来实现记录的修改,删除.
2.可以将文本文件按INI格式保存,两个API实现记录的修改,删除.
Properties=""text;HDR=No;FMT=Delimited"";table=""e:\vb6.0.txt"""
cn.execute "update [e:\vb6.0.txt] set f1='0308008150' where f1='0308008151' and f2='李明'"
cn.execute "delete from [e:\vb6.0.txt] where f1='0308008151' and f2='李明'"