When I load my form, the TextBox.Test = 8 and I would like to change this value during run.
With the new value = 10 and when I reload the next time my form I would like optain the default value for my TextBox = 10
Is't possible?
Thanks a lot
Redg
Printable View
When I load my form, the TextBox.Test = 8 and I would like to change this value during run.
With the new value = 10 and when I reload the next time my form I would like optain the default value for my TextBox = 10
Is't possible?
Thanks a lot
Redg
Yes, if you save a new value in a file, registry or database. VB Code itself cannot remember any changes you make during runtime.
Vlad
One of the ways to do that: Add Microsoft Scripting Runtime reference to the new project, place Text1, Command1 and Command2 on the form. Paste code below, save and run.
option Explicit
private FSO as Scripting.FileSystemObject
private Filer as Scripting.TextStream
private strFile as string
private strValue as string
private Sub Command1_Click()
strFile = App.Path & "\text.txt"
set FSO = new Scripting.FileSystemObject
set Filer = FSO.OpenTextFile(strFile, ForReading, false)
strValue = Filer.ReadLine
Text1.Text = strValue
Filer.Close
set Filer = nothing
set FSO = nothing
End Sub
private Sub Command2_Click()
set FSO = new Scripting.FileSystemObject
set Filer = FSO.OpenTextFile(strFile, ForWriting, false)
Filer.WriteLine Text1.Text
Filer.Close
set Filer = nothing
set FSO = nothing
End Sub
Vlad
You can use WriteProfileString() and GetProfileString() to save and retrieve your values to and from the registry.