请教 vb读取编辑txt文件并保存
vb吧
全部回复
仅看楼主
level 2
3个文本,分别点击读取,在text1输入内容,点击保存 还是保存相应的文件名
嫁入点击读取1.txt 内容显示在text1中,里面修改,点击保存,还是保存为1.txt的文件。
2014年05月10日 01点05分 1
level 8
‘text1的MultiLine为true
text1.text=""
open "C:\1.txt" for input as #1
do until eof(1)
line input #1,a
text1.text=text1.text & a
loop
close
Private Sub Command1_Click()
Open "d:\1.txt" For Output As #1
Print #1, Text1.Text
Close
End Sub
2014年05月10日 02点05分 2
2.txt呢 ?保存按钮就一个哦,那Private Sub Command1_Click() 文件名称就不应该是定值了
2014年05月10日 02点05分
回复 jxyk2007 :要不我把源码发给你。。。
2014年05月10日 02点05分
回复 225148023zxc :保存按钮 就一个,保存文件一直都是1.txt啊。我要点击1.txt,保存的也是1.txt,点击2.txt,保存的也是2.txt ......谢谢。
2014年05月10日 02点05分
level 8
‘text1的MultiLine为true
command1_click
x=1
text1.text=""
open "C:\1.txt" for input as #1
do until eof(1)
line input #1,a
text1.text=text1.text & a
loop
close
end sub
command2_click
x=2
......
end sub
Private Sub Command1_Click()
Open "d:\" & x & ".txt" For Output As #1
Print #1, Text1.Text
Close
End Sub
2014年05月10日 04点05分 3
文件内容 可以读取修改,但是保存的文件名 不对,
2014年05月10日 06点05分
回复 jxyk2007 :你是复制的么。。。
2014年05月10日 07点05分
回复 225148023zxc :对啊,保存名称不会发生变化
2014年05月10日 08点05分
回复 225148023zxc :x的值 不会发生变化 ,所以就生成一个.txt 文件
2014年05月10日 08点05分
level 11

——低调是一种态度
  高傲是一种装逼
   --来自助手版贴吧客户端
2014年05月10日 04点05分 4
。。。。。。。。
2014年05月10日 04点05分
level 2
2014年05月10日 06点05分 5
真不敢相信,你的签名档经验能够通过审核。
2014年05月10日 10点05分
我也只是借用的,好的人都用这个
2014年05月10日 11点05分
level 2
问题解决了,缺少个全局变量 所以x 赋值不过去。谢谢@225148023zxc
Public x
Private Sub Command1_Click()
Open "" & x & ".txt" For Output As #1
Print #1, Text1.Text
Close
End Sub
Private Sub Command2_Click()
x = 1
Text1.Text = ""
Open "1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, a
Text1.Text = Text1.Text & a
Loop
Close
End Sub
Private Sub Command3_Click()
x = 2
Text1.Text = ""
Open "2.txt" For Input As #1
Do Until EOF(1)
Line Input #1, a
Text1.Text = Text1.Text & a
Loop
Close
End Sub
2014年05月10日 12点05分 6
1