VB读写TXT文件的常用方法
Private Sub Command1_Click() ‘读文件
Open “c:\xqlab.txt“ For Input As #1
Dim Lines As String
Dim NextLine As String
Dim i As IntegerClose #1
Text1.Text = Lines
End Sub Private Sub Command2_Click() ‘写文件
Open “c:\xqlab.txt“ For Output As #1
Print #1, Text1.Text
Close #1
End Sub ‘如果要处理的是程序目录所在的xqlab.txt那么应该是这样写:
‘Open app.path+”\xqlab.txt” For Input As #1
Open “c:\xqlab.txt“ For Input As #1
Dim Lines As String
Dim NextLine As String
Dim i As IntegerClose #1
Text1.Text = Lines
End Sub Private Sub Command2_Click() ‘写文件
Open “c:\xqlab.txt“ For Output As #1
Print #1, Text1.Text
Close #1
End Sub ‘如果要处理的是程序目录所在的xqlab.txt那么应该是这样写:
‘Open app.path+”\xqlab.txt” For Input As #1
Do While Not EOF(1)
On Error Resume Next
Line Input #1, NextLine
Lines = Lines & NextLine & Chr(13) & Chr(10)
Loop
本文链接:
http://www.xqlab.com/html/y2009/360.html
转载请注明出处:Xqlab’s Blog [http://www.xqlab.com]


















xqlab Reply:
八月 31st, 2009 at 21:09
那应该如何写?一起研究一下