哪位高手帮我写个VB小程序!高分!

来源:百度知道 编辑:UC知道 时间:2024/07/01 12:51:54
我现在要源码 谁能帮我整一个打开一个文件并对他进行替换处理个别数据然后再保存的一个小VB程序?举例讲,我打个个1234.txt文件,然后把里面的全部1替换成3 全部4替换成0,然后再保存回去。就这个功能。
怎么使用啊?对不起 我是个菜鸟!

我以前做过个类似的。你给个邮箱,我改好了发给你,,

dim s as string,a as string
open "1234.txt" for input as #1
while eof(1)
input #1,a
s=s+a
wend
close(1)
s=replace(s,"1","3")
s=replace(s,"4","0")
open "123456" for output as #1
print #1,s
close(1)

Private Sub Command1_Click( )
Dim Lstr as String
Dim strSave as string
Open "C:\\mytext.txt" For input As #1
Do While Not EOF(1)
Line Input #1, Lstr
Lstr=Replace(Lstr,"1","3")
Lstr=Replace(Lstr,"4","0")
strSave=strSave+Lstr
'避免文本内容过大,一行一行替换
Loop
Close #1
open "C:\\mytext.txt" for output as #1
print #1,strSave
Close #1
End Sub

打开VB,创建新模块,创建一个按钮(command),打开编码层,贴上三楼的代码,ok