|
-
Sep 12th, 2000, 04:55 AM
#1
I want to store some variables within the EXE file itself so that when the program is closed and re-run, the variables will still be remembered.
The variables are from a textbox which asks the user for his name. I want to be able to store it so that it can greet him on his next use.
how do i go abt doing this?
thx
-
Sep 12th, 2000, 04:56 AM
#2
_______
<?>
Code:
'
'another opiton is to use SaveSetting and GetSetting
Option Explicit
'
' Variant to hold 2-dimensional array returned by GetSetting.
Dim MySettings As Variant
'to test this out
'make a std project
'add a textbox with "" value for text
'add command1 and command2
'run the app
'click command1
'click the x to unload the project
'reload the project and text1 will now have the text that
'was in it when you quit
'if you want to delete the save settings click on command2
Private Sub Command2_Click()
'this will delete it from the register if you are finished
'with playing with it
DeleteSetting "project1", "TextboxValue"
End Sub
Private Sub Form_Load()
'this will load it into the register
Text1.Text = GetSetting("project1", "TextboxValue", "Value", 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'this will save it into the register when you quit
SaveSetting "project1", "TextboxValue", "Value", Text1.Text
End Sub
Private Sub Command1_Click()
'load the text1.text with whatever
Text1.Text = "Shame on you, you went and did it!"
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 12th, 2000, 04:59 AM
#3
thanks, but what do you recommend if i dont want to play around with the registry?
-
Sep 12th, 2000, 05:20 AM
#4
I dont want to use the registry because the app will be like a greeting card. You enter a name and then send it off to the receipient.
-
Sep 12th, 2000, 05:20 AM
#5
Hyperactive Member
You could try writing the variables in question to an external file, and read them into the program when needed.
-
Sep 12th, 2000, 05:30 AM
#6
I tried it but i want to keep the no. of files distributed to the minimum. You know like those messagemates, you can configure it and then it saves into the file itself
-
Sep 12th, 2000, 05:33 AM
#7
Addicted Member
I think you should use the WritePrivateProfileString and SetPrivateProfileString API calls. With these call you can create an INI file and store info in there.
-
Sep 12th, 2000, 05:36 AM
#8
Hyperactive Member
Whether it is an *.ini file or just a normal text file, it looks as if you are going to have to write to as file. A typical text file might be 256 bytes or less. It hardly counts as a file compared to the size of the distributed *.exe.
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
|