Option Explicit Dim sj Private Sub Form_Load() On Error GoTo UError Open "c:\data.txt" For Input As #1 Input #1, sj Close Text1 = sj UError: End SubPrivate Sub Form_Unload(Cancel As Integer) sj = Text1 Open "c:\data.txt" For Output As #1 Write #1, sj Close End Sub
'修改一下楼上的Option Explicit Dim sj$ Private Sub Form_Load() If Dir("c:\data.txt") <> "" Then Open "c:\data.txt" For Input As #1 Line Input #1, sj Close #1 Text1.Text = sj End If End SubPrivate Sub Form_Unload(Cancel As Integer) sj = Text1.Text Open "c:\data.txt" For Output As #1 Print #1, sj Close #1 End Sub
Option Explicit
Dim sj
Private Sub Form_Load()
On Error GoTo UError
Open "c:\data.txt" For Input As #1
Input #1, sj
Close
Text1 = sj
UError:
End SubPrivate Sub Form_Unload(Cancel As Integer)
sj = Text1
Open "c:\data.txt" For Output As #1
Write #1, sj
Close
End Sub
Dim sj$
Private Sub Form_Load()
If Dir("c:\data.txt") <> "" Then
Open "c:\data.txt" For Input As #1
Line Input #1, sj
Close #1
Text1.Text = sj
End If
End SubPrivate Sub Form_Unload(Cancel As Integer)
sj = Text1.Text
Open "c:\data.txt" For Output As #1
Print #1, sj
Close #1
End Sub
http://download.csdn.net/source/374797