-
Oct 31st, 2000, 05:15 PM
#1
Thread Starter
New Member
I am a beginner and need a little help with the basics.
Am using VB6.
My entire program consists of 1 Form and a textbox. I want the program to remember the text in the textbox when the app is loaded
Entire Code:
Private Sub Form1_Load()
Text1.Text = GetSettings("MyApplication", "TextboxValue", "Value", "No Data")
End Sub
Private Sub Form1_Unload(Cancel As Integer)
SaveSettings "MyApplication", "TextboxValue", "Value", Text1.Text
End Sub
When I run it It doesnt save the text in the Text box.
Can you help please
-
Oct 31st, 2000, 05:26 PM
#2
Addicted Member
That's because the value in the TextBox has been cleared. Instead in Unload event, put your SaveSettings code in Form_QueryUnload event.
-
Oct 31st, 2000, 05:40 PM
#3
Thread Starter
New Member
Thanks Arcom!
I have tried that and it now tells me I have a compile error. Sub or Function not defined.
Can you help please
Thaks Peter2000
-
Oct 31st, 2000, 06:04 PM
#4
_______
<?>
Code:
'remember to use the x on the form to exit as that is what
'will trigger the form_unload cancel
'another opiton is to use SaveSetting and GetSetting
Option Explicit
'
' Variant to hold 2-dimensional array returned by GetSetting.
Dim MySettings As Variant
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
-
Nov 2nd, 2000, 01:39 PM
#5
Addicted Member
And can you tell me what's the difference between your and Peter's code??? You just added two command buttons and one unused variable. For what?
Here's plain and simple:
Private Sub Form_Load()
Text1.Text = GetSetting(App.Title, "Settings", "TextBoxValue", "Default data")
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
SaveSetting App.Title, "Settings", "TextBoxValue", Text1.Text
End Sub
BTW: The compile error is because you used SaveSettings which doesn't exist as a sub or function. Use SaveSetting instead.
-
Nov 2nd, 2000, 01:55 PM
#6
_______
<?>
I'll be happy to explain the difference between Peter's code and the code I posted. However, just because you don't understand the code you shouldn't be critizing it with such vigor.
The 2nd command button is not useless as it removes the entry from the registery...unless of course you don't mind filling your registery with garbage.
If you had tested the code you would see that it works.
The variable was useless as it was a hangover from prior code. No big deal. Shoot me dead..I forgot to clean up my database.
Simple truth is you shouldn't behave like a spoiled brat just because your first attemt at answering it was wrong.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 3rd, 2000, 09:29 AM
#7
Addicted Member
Sorry HeSaidJoe, but I wasn't critisizing anyone...
But i still think that those two buttons are useless.
That's my opinion, and you don't have to agree with that.
Like you said: "Shoot me dead..."
And BTW: I NEVER SAID THAT YOUR CODE DOESN'T WORK.
-
Nov 3rd, 2000, 12:03 PM
#8
_______
<?>
I can live with that.
The buttons are useless: but remember, the buttons in themselves are the containers .....you can put the code anywhere you want, I just happened to put them inside buttons. It's not the container that is the answer, the container only holds the answer.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|