[求助]请教如何使用VB文本框实现记忆功能?
我是一个VB初学者,我想使两个文本框(一个填写的“用户名”,一个填写“密码”)中输入的内容在程序下次启动时候还保存着,这样必须有一个文件用来保留输入的内容? 但是总是搞不定。我编写的如下:
Private Sub Text2_LostFocus()
Dim strtemp As String
Dim strfilecontents As String
Open "user.txt" For Output As #1
Print #1, Text2.Text
Close #1
Open "user.txt" For Input As #1
While Not EOF(1)
Line Input #1, strtemp
strfilecontents = strfilecontents & strtemp & vbCrLf
Wend
Close #1
End Sub
Private Sub Text3_LostFocus()
Dim strtemp As String
Dim strfilecontents As String
Open "user2.txt" For Output As #2
Print #2, Text3.Text
Close #2
Open "user2.txt" For Input As #2
While Not EOF(1)
Line Input #2, strtemp
strfilecontents = strfilecontents & strtemp & vbCrLf
Wend
Close #2
End Sub
Private Sub Form_Load()
Dim readtext As String
Dim readtext2 As String
Open "user.txt" For Input As #1
While Not EOF(1)
Line Input #1, readtext
Text2.Text = Text2.Text & readtext & vbCrLf
Wend
Close #1
Open "user2.txt" For Input As #2
While Not EOF(1)
Line Input #2, readtext2
Text3.Text = Text3.Text & readtext2 & vbCrLf
Wend
Close #2
End Sub
代码一大堆问题,请大虾不要笑话!
而且修改了文本框里的内容后,文件的内容也不会随着改变,而且我想只使用一个文件来保留(用二进制文件,这样保密性好点) ,又该怎么实现呢?