Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009

    Unanswered: Need help with command button displaying option button choices!!! IM NEW....

    Hey guys,
    I saw that this forum is really helpful. I decided to create an account. Im new to VB6 and I have a problem
    I have to display a welcome message for a project. I have created 3 welcome messages for the user to choose from and I have a command button to display the welcome message in the label box.
    How do I make the command button display the message that the user has selected in the label box?
    My button name is : cmdDisplay
    My three option buttons are : optMessage1, optMessage2, and optMessage3
    My label box is: lblMessageoftheDay
    If someone could just make me the code or give a an explanation on how to do it, I will greatly appreciate it.
    Thanks again guys!

  2. #2
    Join Date
    Jul 2009
    come on someone help me pleaseeee

  3. #3
    Join Date
    Jun 2004
    Arizona, USA
    Please don't bump until enough time has elapsed - a day or so.

    We need more information. Do you want the app to keep the last selection chosen, so that the next time it runs, that option is displayed?

    If so, you need to store it somewhere. You could use the registry, and VB's built-in getsetting and savesetting functions to retrieve/store it.

    You would be better served if you create an ARRAY of option buttons, rather than three separately named option buttons. optMessage(0), optMessage(1), and optMessage(2). They have the same name, but each has a different index number.

    This index is then used when the user clicks the button. THere is a single click event, with index as a property.

    Inside the optionbutton click event code, save the value of index to the registry.

    SaveSetting App.Title,  "Settings" , "MessageNumber", cstr(Index)
    me.label1.caption = me.OptionButtonName(Index).Caption
    And, in the form load event, you need to fetch the saved option button number, and set the current option to this
    Dim N as Integer
    N = Cint(GetSetting(app.ExeName, "Settings", "MessageNumber", "0"))
    me.OptionButtonName(N).Value = True
    me.label1.caption = me.OptionButtonName(N).Caption
    If you wanted, you could use the option button's TAG property to hold the actual message that will be displayed, and have a description of the contents in the optionbutton caption.
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts