Results 1 to 8 of 8

Thread: Unclear Answer......

  1. #1

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    ok, I posted in the form wanting to know how to save the button click so that next time the user loads the program, the button is how the left it...

    They used the SaveSetting and GetSetting functions to explain it, but when I do this...

    Private Sub mnuAny_Click()
    mnuAny.Checked = Not mnuAny.Checked
    SaveSetting "Test", "Test Program", "thecheckvalues...", Check1.Value = True
    End Sub

    Private Sub Form_Load()
    mnuAny.Checked = True = GetSetting("Test Program", "Test Program", "thecheckvalues", 0)
    End Sub

    I get "cant be set on this control" and I am using it on a menu...because thats what they used when telling me what to do... when I try to use this on the Check1.value = 1 statement...it wont work..

    So I want to do this, but how?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Code:
    Private Sub mnuAny_Click() 
      mnuAny.Checked = Not mnuAny.Checked 
      SaveSetting App.Title, "Menu Status", "mnuAny", Check1.Value 
    End Sub 
    
    Private Sub Form_Load() 
      mnuAny.Checked = GetSetting(App.Title, "Menu Status", "mnuAny", False) 
    End Sub
    Try this instead... thought I don't really like the fact you store and retrieve a non-string value though I assume the GetSetting/SaveSetting handles it.

    If it doesn't try it like this

    Code:
    Private Sub mnuAny_Click() 
      mnuAny.Checked = Not mnuAny.Checked 
      If mnuAny.Checked Then
        SaveSetting App.Title, "Menu Status", "mnuAny", "Yes" 
      Else
        SaveSetting App.Title, "Menu Status", "mnuAny", "No"
      End If
    End Sub 
    
    Private Sub Form_Load() 
      If GetSetting(App.Title, "Menu Status", "mnuAny", "No") = "Yes" Then
        mnuAny.Checked = True
      Else
        mnuAny.Checked = False 
      End If
    End Sub
    I would also try and get something standard going with the values you give to GetSetting/SetSetting.

    App.Title - Copies the name that you have given your VB project therefor if it changes so does the settings saved

    "Menu Status" - You should group things together logically so that you have one area specifically for Menu Statuses

    "mnuAny" - This is the actual control that is being changed. Using the name that matches it give you more idea what is actually being set.

    If you stick to these kinds of guidelines your program will remain neat and structured

  3. #3

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    see thats what I dont get...

    what do I make the mnuAny? A menu button? or a Click button?

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Think about it for a moment.

    If it is a "click" button then it goes down when you press it... and comes back UP when you let it go.

    How then can you "save" what the user last did to it when it always comes back up afterwards!?!??!

    You used the variable "mnuAny" when you gave your example which suggests by standard naming conventions you have set up a Menu Item using the Menu Editor.

    It also logically suggests a Menu Button because you used the attribute "Checked". A Click Button doesn't have a "Checked" attribute because it is never "Checked".

    Why would you even WANT to make it a click button?!?!?!

  5. #5

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    What do you mean? A lot of programs use them...
    I think there was some confusion when I said check button... I actually took the time to read it and I meant Check Box...

    Sorry about the wrong name...if that caused my misunderstanding....


    [Edited by Sacofjoea on 06-28-2000 at 06:35 PM]

  6. #6
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    You actually said "CLICK button" not "CHECK button"

    I understand what you mean now... Its either a menu item or its a checkbox. Standard Variable naming practices would therefor be like this.

    mnuAny - A Menu Item
    chkAny - A CheckBox

    chkAny.Checked = vbChecked
    chkAny.Checked = vbUnchecked

    You can still use the same code above, I would use the code that saves a Yes or a No as text and then converts it to whatever the control needs to programmatically "set" and "unset" itself.

  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    same stuff different version....

    Private Sub Form_Load()

    If GetSetting(appname:="Project1", section:="Startup", _
    Key:="Form1") = "1" Then
    Check1.Value = 1
    Else
    Check1.Value = 0
    End If

    End Sub

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    If Check1.Value = 1 Then
    SaveSetting appname:="Project1", _
    section:="Startup", _
    Key:="Form1", _
    setting:="1"
    Else
    SaveSetting appname:="Project1", _
    section:="Startup", _
    Key:="Form1", _
    setting:="0"
    End If

    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

  8. #8

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    Thanks HeSaidJoe, that worked perfectly!

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