View Single Post
Pro contributor
12Mar2010,16:24  
virxen's Avatar
with the file method
==================
you need a form with a textbox named text1

Code:
Option Explicit
Dim filename As String
Dim filepath As String
Dim text As String

Private Sub Form_Load()'when you load form ,checks if the file exists and reads data and stores to text var. and textbox1
filename = "datastore.txt"
filepath = App.Path + "\" + filename
Dim f As Integer
f = FreeFile
If Dir(filepath) = filename Then
Open filepath For Input As #f
Line Input #f, text
Text1.text = text
Close #f
End If
End Sub

Private Sub Form_Terminate()'when the form terminates,exits-->save text to file
Dim f As Integer
f = FreeFile
Open filepath For Output As #f
Print #f, text
Close #f
End Sub

Private Sub Text1_Change()'when you alter text save it to text variable
text = Text1.text
End Sub
viv345 like this