如何程序保存用户输入到文本框中的数据

来源:百度知道 编辑:UC知道 时间:2024/05/30 14:51:13
即,程序界面有一个文本框,用户输入一定文字,点击了确定,就会把它保存到一个指定文本文件中。

楼上的方法有点麻烦,还有添加控件
看这个

'你先建一个Text1和Command1

Private Sub Command1_Click()
Open "D:\qmn.txt" For Output As #1 '...............打开D:\qmn.txt
Print #1, Text1.Text '.......................................输入Text1.Text内容
Close #1 '........................................................关闭qmn.txt
End Sub

Private Sub baocun_Click()
CommonDialog1.CancelError = True
CommonDialog1.Filter = "文本文档(*.txt)|*.txt"
CommonDialog1.DialogTitle = "保存"
On Error GoTo Cancel
CommonDialog1.ShowSave
Open CommonDialog1.FileName For Output As #1
Print #1, Text1.Text
Close #1
Cancel:
End Sub

先加载一个 CommonDialog1