VB 如何保存Text 中的内容为(.txt)格式
发布网友
发布时间:2024-03-05 18:29
我来回答
共1个回答
热心网友
时间:2024-08-02 09:19
建一个Text1,Command1,Command2,代码如下。
==================
Private Sub Command1_Click()
Open "d:\thc\测试.txt" For Output As 1
Write #1, Text1.Text
Close 1
MsgBox "保存完毕"
End Sub
Private Sub Command2_Click()
Open "d:\thc\测试.txt" For Input As 1
Do While EOF(1) = False
Dim s As String
Line Input #1, s
Text1.Text = Text1.Text & s
Loop
Close 1
End Sub
Private Sub Form_Load()
Command1.Caption = "保存"
Command2.Caption = "还原" '个人认为叫做“打开”更好
Text1.Text = ""
End Sub