1:将txt文件内容全部添加到text1文本框:
Private Sub Form_Load() '加载txt文件
Open App.Path & "\1.txt" For Input As #1
Text1 = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
End Sub
2:从txt文件中逐行(段落)添加到文本框:
Private Sub Form_Load() '加载txt文件
Open App.Path & "\1.txt" For Input As #1
End Sub
Private Sub Command1_Click() '开始阅读
Dim str As String
On Error Resume Next
Line Input #1, str
Text1.SelText = str & vbCrLf
End Sub
Private Sub Command2_Click() '从头再看
Close #1
Text1 = ""
Form_Load
End Sub
Private Sub Form_Load() '加载txt文件
Open App.Path & "\1.txt" For Input As #1
Text1 = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
End Sub
2:从txt文件中逐行(段落)添加到文本框:
Private Sub Form_Load() '加载txt文件
Open App.Path & "\1.txt" For Input As #1
End Sub
Private Sub Command1_Click() '开始阅读
Dim str As String
On Error Resume Next
Line Input #1, str
Text1.SelText = str & vbCrLf
End Sub
Private Sub Command2_Click() '从头再看
Close #1
Text1 = ""
Form_Load
End Sub