If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Need help with command button displaying option button choices!!! IM NEW....

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-02-09, 12:16
warlord999 warlord999 is offline
Registered User
 
Join Date: Jul 2009
Posts: 2
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!
Reply With Quote
  #2 (permalink)  
Old 07-02-09, 13:07
warlord999 warlord999 is offline
Registered User
 
Join Date: Jul 2009
Posts: 2
come on someone help me pleaseeee
Reply With Quote
  #3 (permalink)  
Old 07-02-09, 17:41
loquin loquin is online now
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,777
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.

Code:
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
Code:
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.
__________________
Lou
使大吃一惊
"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

Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On