|
-
March 15th, 2001, 02:57 PM
#1
Change default value in TextBox.Text
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
-
March 15th, 2001, 03:04 PM
#2
Re: Change default value in TextBox.Text
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
-
March 15th, 2001, 03:21 PM
#3
Re: Change default value in TextBox.Text
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
-
March 15th, 2001, 09:49 PM
#4
Re: Change default value in TextBox.Text
You can use WriteProfileString() and GetProfileString() to save and retrieve your values to and from the registry.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|