vb逐行读取和逐行写入txt的问题 !!!

现在有三个文本框 单击command1把三个文本框的内容保存到txt文件中 路径就为c:\xxx.txt吧 每个文本框的内容为一行 一共写入三行 窗体加载时 三个文本框分别读取每行的内容 显示文本框中 我自己写了代码 但是每次保存的时候 每行之间会有空行 读取也无法按每行读取 有时会提示 input past end of file错误 但是代码应该是没错的 现在要上班 晚上贴出代码 哪位能给出参考代码也可 thx so much!!!

第1个回答  2012-03-15
试试这个吧
Private Sub Command1_Click()
Open "c:\123.txt" For Output As #1
Print #1, Text1
Print #1, Text2
Print #1, Text3
Close
End Sub

Private Sub Form_Load()
Open "c:\123.txt" For Input As #1
Input #1, a
Input #1, b
Input #1, c
Text1 = a
Text2 = b
Text3 = c
Close
End Sub本回答被提问者采纳
第2个回答  2012-03-13
用这个:
Option Explicit

Private Sub Command1_Click()
Dim InPutData
Open App.Path & "\中文\" & Text2.Text & ".txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InPutData
Text1.Text = Text1.Text + InPutData + vbCrLf
Loop
Close #1
Dim ass
Open App.Path & "\英文\" & Text2.Text & "e.txt" For Input As #2

Text4.Text = Text4.Text + ass

Close #2
End Sub

Private Sub Command2_Click()
End
End Sub
相似回答