VB读取TXT并显示出来

例如我D盘有一个里面有数据的文本1.TXT

我想做个按扭把里面的数据显示到TEXT1.TEXT里 并可以修改内面的数据保存回1。TXT里

第1个回答  推荐于2016-09-18

Private Sub Command1_Click()
Open "d:\1.txt" For Input As #1
Dim Lines As String
Dim NextLine As String
Dim i As Integer
Do While Not EOF(1)
On Error Resume Next
Line Input #1, NextLine
Lines = Lines & NextLine & Chr(13) & Chr(10)
Loop
Close #1
Text1.Text = Lines
End Sub


Private Sub Command2_Click()
Open "d:\1.txt" For Output As #1
Print #1, Text1.Text
Close #1

End Sub本回答被提问者采纳
相似回答