vb读取txt文件并把内容显示在textbox控件中

比如我知道一个txt文件abc.txt
怎样把这个文件内的内容显示到text1.text中啊?
忘记说了,如何把textbox控件内容替换掉原来txt文件中的内容
假设txt文件在C根目录下

第1个回答  2009-07-31
Private Sub Command1_Click()
Dim s As String
Dim a As String

Open "c:\abc.txt" For Input As #1
If Not EOF(1) Then
Input #1, s
End If
While Not EOF(1)
s = s & vbCrLf
Input #1, a
s = s & a
Wend
Close #1

Text1.Text = s

End Sub

是要把文本框内容存到文件还是
第2个回答  2009-07-31
读取文件:
Dim InputData As String*1
Open"C:\abc.txt" For Input As #1
Do While Not EOF(1)
InputData=Input(1,#1)
Text1.Text=Text1.Text+InputData
Loop
Close#1
替换原来文件的内容:
Dim OutputData As String
Open"C:\abc.txt" For Output As #1
Print#1,Text1.Text
Close#1
相似回答