
VB里的Check控件有打勾的时侯就永久保存Text1和Text2上所写的文字 下次打开程序的时侯也会自动出现
1个回答
展开全部
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询