level 2
如何实现在Text1.Text中保存上次退出是Text1.Text中显示的信息,也即在下次打开时Text1.Text显示的是上次退出时Text1.Text的值
2010年05月06日 07点05分
1
level 3
在当前目录 创一个 文本文件 当你 退出程序的时候 , 就把 text1.text 写入 那个文本文件, 当打开的时候 读取就行了
2010年05月06日 09点05分
2
level 7
'正常退出的情况下可以完成保存text1的内容。
'实用于单个控件属性的保存 多个需要一些处理。
Private Sub Form_Load()
If Dir(App.Path & "\1.txt") <> "" Then '检测文件是否存在
Open App.Path & "\1.txt" For Input As #1
If Not EOF(1) Then '检测文件是否为空文件
Line Input #1, tmp
End If
Close #1
Text1.Text = tmp
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open App.Path & "\1.txt" For Output As #1
Print #1, Text1.Text
Close #1
End Sub
2010年05月06日 18点05分
3
level 2
回复:3楼
非常感谢!!!
不但给出解题思路,连代码都给出来了,又让我长知识了
2010年05月07日 00点05分
5
level 12
怎么总是报错误?
Private Sub Command1_Click()
If MsgBox("保存吗?", vbOKCancel, "保存") = vbOK Then
Open "test.txt" For Output As #1
Print #1, Text1
Print #1, Text2
Print #1, Text3
Print #1, Text4
Print #1, Text5
Print #1, Text6
Print #1, Text7
Print #1, Text8
Print #1, Text228
Close #1
End If
End Sub
Private Sub Form_Load()
If Dir("test.txt", vbSystem) <> "" Then
Open "test.txt" For Input As #1
Line Input #1, s1
Line Input #1, s2
Line Input #1, s3
Line Input #1, s4
Line Input #1, s5
Line Input #1, s6
Line Input #1, s7
Line Input #1, s8
Line Input #1, s228
Close #1
Text1 = s1
Text2 = s2
Text3 = s3
Text1 = s4
Text2 = s5
Text3 = s6
Text1 = s7
Text2 = s8
Text3 = s228
End If
End Sub
2014年11月06日 23点11分
7
level 1
可以用注册表保存,比如使用以下函数/过程:
SaveSetting/GetSetting/GetAllSettings/DeleteSetting
这样稍微方便一些,使用方法请参考MSDN;
这是一个例子:
Option Explicit
Private Sub Form_Load()
Text1.Text = GetSetting(App.EXEName, "Main", "Text1", "Text1")
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting App.EXEName, "Main", "Text1", Text1.Text
End Sub
2020年12月16日 08点12分
9