VB中如何保存Text控件中的文字

来源:百度知道 编辑:UC知道 时间:2024/06/15 23:49:19
就是说忘一个名为Text1的控件中输入字符,关闭该程序,再打开的时候,Text1中的字符是上次输入的字符

可以用 Open 方法打开一个文件,把内容写进去。然后软件运行时首先也是打开这个文件读进来。

写:
open "路径文件名" for output as #1
print #1,text1.text
close #1

读:
open "路径文件名" for output as #1
do while not EOF(1)
line input #1 , readtext
text1.text=text1.text & readtext & vbcrlf
loop

在窗体卸载过程中写代码,建立一个数据文件,随便怎么命名,将输入的字符保存在这个文件中,打开程序时读出数据文件中的数据.

Private Sub Command1_Click()
Open App.Path & "/01.txt" For Binary As #1
Text1 = Input(LOF(1), 1)
Close #1
End Sub

Private Sub Command2_Click()
Open App.Path & "/01.txt" For Output As #1
Print #1, Text1.Text
Close #1
End Sub

做一个配置文件