|
-
Oct 11th, 2000, 10:18 AM
#1
Thread Starter
Junior Member
hi
is there anyone out there who might be kind enough to write a small example of how to save and retreive the value of a checkbox on a form(checked or unchecked)so that the same condition is returned the next time the app. is run 'cos i am really struggling with this one folks!!
Thanks in advance for any help
-
Oct 11th, 2000, 10:32 AM
#2
Frenzied Member
Code:
Private Sub Form_Load()
Dim value As String
Open App.Path & "\options.txt" For Input As #1
Input #1, value
Check1.value = value
Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open App.Path & "\options.txt" For Output As #1
Print #1, Check1.value
Close
End Sub
Create a file, options.txt in the path of your app with 0 or 1 in it (only needed the first time) and then run the code and VOILA!
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 11th, 2000, 10:40 AM
#3
Lively Member
Is there a specific reason why you want this in a file? If not use the Registry
Code:
SaveSetting App.Title, "Settings", "CheckBoxState", check1.value
check1.value = GetSetting(App.Title, "Settings", "CheckBoxState", vbUnchecked)
Anakim
It's a small world but I wouldn't like to paint it.
-
Oct 11th, 2000, 11:08 AM
#4
Frenzied Member
Yeah you're right, the registry is a better Idea, but what's this?
Code:
check1.value = GetSetting(App.Title, "Settings", "CheckBoxState", vbUnchecked)
Wouldn't that always get the vbUnchecked in the checkbox?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 11th, 2000, 12:21 PM
#5
Hyperactive Member
Code:
check1.value = GetSetting(App.Title, "Settings", "CheckBoxState", vbUnchecked)
SaveSetting App.Title, "Settings", "CheckBoxState", check1.value
try those
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Oct 11th, 2000, 12:48 PM
#6
Lively Member
why vbUnChecked
PRIVATE1, I'm with Jop, wouldn't that always open the form with the checkbox unchecked?
-
Oct 11th, 2000, 04:46 PM
#7
Lively Member
No. The vbunchecked bit would be the default value. ie. if the GetSetting is performed in the form_load event and the app has never been used before there will not be a registry setting, therefore GetSetting returns 'unchecked'. The SaveSetting will create a registry entry if there isn't one or update one if there is.
Took a while to respond - time lapse between England's hard fought heroic point against the mighty Fins, food, and the Jocks putting us to shame with a good performance against a side just a tad better than Finland.
Anakim
It's a small world but I wouldn't like to paint it.
-
Oct 11th, 2000, 05:01 PM
#8
I'm a kind person .
Take a look at this thread.
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
|