Results 1 to 8 of 8

Thread: need help from a kind person

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    23

    Unhappy

    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

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.

  3. #3
    Lively Member
    Join Date
    Jun 2000
    Location
    A caravan park in the Midlands (UK)
    Posts
    101
    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.

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.

  5. #5
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    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 !!!!!

  6. #6
    Lively Member
    Join Date
    Feb 2000
    Posts
    118

    why vbUnChecked

    PRIVATE1, I'm with Jop, wouldn't that always open the form with the checkbox unchecked?
    Kokopeli
    VB6 SP3

  7. #7
    Lively Member
    Join Date
    Jun 2000
    Location
    A caravan park in the Midlands (UK)
    Posts
    101

    Wink

    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.

  8. #8
    Guest
    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
  •  



Click Here to Expand Forum to Full Width