I need to save the values of several variables to a text file can somebody please give me an example of the code used to save the variables named (var1, var2, var3, var4, var5) to a text file and then retrieve them.
Printable View
I need to save the values of several variables to a text file can somebody please give me an example of the code used to save the variables named (var1, var2, var3, var4, var5) to a text file and then retrieve them.
the "sandbox" project at the link below my name show how to read and write text files
take this code and change the print line to your variable. ie..Code:On Error GoTo fileerror
' creates a file if one is not made
'and writes what is in text box, output overwrites and append adds to
Open "c:\text.txt" For Append As #1
Print #1, Text1.Text
Close #1
Exit Sub
fileerror:
MsgBox "file error"
Print #1, var1
and so on
good luck
Alternatly:
You may want to investigate .ini files or the Registry to save and retrieve data.
Bruce.