VB里的Check控件有打勾的时侯就永久保存Text1和Text2上所写的文字 下次打开程序的时侯也会自动出现

当然,不打勾的时侯就会不保存下次打开的时侯就会是空白啊,就像QQ上的记住密码那样... 当然,不打勾的时侯就会不保存 下次打开的时侯就会是空白啊,就像QQ上的记住密码那样 展开
 我来答
网海1书生
科技发烧友

2013-04-30 · 擅长软件设计、WEB应用开发、小程序
网海1书生
采纳数:12315 获赞数:26246

向TA提问 私信TA
展开全部
Private Sub Form_Load()
If Dir(App.Path & "\1.txt") <> "" Then
Open App.Path & "\1.txt" For Binary As #1
Text1.Text = Input(LOF(1), #1)
Close #1
Check1.Value = 1
End If
If Dir(App.Path & "\2.txt") <> "" Then
Open App.Path & "\2.txt" For Binary As #1
Text2.Text = Input(LOF(1), #1)
Close #1
Check1.Value = 1
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Dir(App.Path & "\1.txt") <> "" Then Kill App.Path & "\1.txt"
If Dir(App.Path & "\2.txt") <> "" Then Kill App.Path & "\2.txt"
If Check1.Value = 1 Then
Open App.Path & "\1.txt" For Output As #1
Print #1, Text1.Text
Close #1
Open App.Path & "\2.txt" For Output As #1
Print #1, Text2.Text
Close #1
End If
End Sub

用到的三个控件分别是Check1、Text1、Text2
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式