|
-
Jan 24th, 2010, 09:15 AM
#1
Thread Starter
Lively Member
How do I creat a line of buttons?
Hi All!
I want to creat 4 or 5 buttons
that the user can press only one button each time.
When a button is pressed the other ones are at off state.
Does the Visual Basic have such buttons?
If yes, How can I add those components?
Thanks a lot!
Y
-
Jan 24th, 2010, 09:27 AM
#2
Re: How do I creat a line of buttons?
When user Click one buttons, disable other buttons.
WHta'is your problem...?
-
Jan 24th, 2010, 09:27 AM
#3
Re: How do I creat a line of buttons?
Yes, they're called OptionButtons, which are also known as Radio Controls or Radio Buttons. They are standard controls that should be in your Tool Box. Only one can be clicked (selected) at a time.
Last edited by CDRIVE; Jan 24th, 2010 at 09:34 AM.
Reason: Append
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 24th, 2010, 09:51 AM
#4
Thread Starter
Lively Member
Re: How do I creat a line of buttons?
How I add them to the Tool Box?
-
Jan 24th, 2010, 10:50 AM
#5
Re: How do I creat a line of buttons?
Li9erYol
When you click the Toolbox icon on the menu bar, do you
see a "recessed" white circle with a black dot in the center
(when you move your mouse over it, it should read OptionButton)?
That is, it should already be in the ToolBox, so you don't need to
add it "to the ToolBox"
If you mean, how do you add it to a form, then one way is to
1. add a Frame to the form
2. add an OptionButton to the Frame.
3. copy (Ctrl-C) the OptionButton, and paste it (Ctrl-V) to the Frame (not the form)
4. You will get a dialogue box asking you if you want to create a control array. Click YES.
5. Repeat step 3 (you won't be asked any more about creating a control array)
When you have put the 5 OptionButtons on the Frame, they will "act together"
since they are all within a common control (ie, the Frame)
HTH
Spoo
-
Jan 24th, 2010, 11:08 AM
#6
-
Jan 24th, 2010, 11:20 AM
#7
Re: How do I creat a line of buttons?
CDRIVE
Oops.. thanks for the correction. Who knew?
Spoo
-
Jan 24th, 2010, 12:09 PM
#8
Re: How do I creat a line of buttons?
 Originally Posted by Spoo
CDRIVE
Oops.. thanks for the correction. Who knew?
Spoo
It's putting them in Frames or other controls that make them independent of other OptionButtons on the Form. If you put 3 OB's on the Form and 3 OB's in a Frame the two groups of three will be independent of each other.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 24th, 2010, 12:27 PM
#9
Re: How do I creat a line of buttons?
And to add one more thing. If you don't want the radio button visual effect, you can set the option button's Style property to Graphical then they will appear like command buttons, with a slight twist.
-
Jan 25th, 2010, 01:35 PM
#10
Re: How do I creat a line of buttons?
 Originally Posted by LaVolpe
And to add one more thing. If you don't want the radio button visual effect, you can set the option button's Style property to Graphical then they will appear like command buttons, with a slight twist.
Now you tell me! 
After over 20 years I never knew this existed and always used command buttons to illustrate multiple choice question options (A, B, C, D, or E). The option buttons were always there for the taking and I think they look better and would have worked better for indicating a choice. I have half a dozen VB reference books that failed to address this. Gasp!
-
Jan 25th, 2010, 01:58 PM
#11
Re: How do I creat a line of buttons?
 Originally Posted by Code Doc
Now you tell me!
After over 20 years I never knew this existed and always used command buttons to illustrate multiple choice question options (A, B, C, D, or E). The option buttons were always there for the taking and I think they look better and would have worked better for indicating a choice. I have half a dozen VB reference books that failed to address this. Gasp! 
Then don't set the CheckBox property to Graphical, else you may blow a gasket
-
Jan 25th, 2010, 04:04 PM
#12
Re: How do I creat a line of buttons?
 Originally Posted by LaVolpe
Then don't set the CheckBox property to Graphical, else you may blow a gasket 
Well, that check box isn't so exasperating. Seldom do authors of test items allow for more than one answer to an objective question, such as multiple choice or true/false. However, having an option for the standard check mark would have been a pleasant change on occasion for multiple topic selections.
Alas, Fox, that is not what has led to my demise. Not being able to port my VB6 programs directly into the Macintosh has sounded the death knoll. It's a classic case of the sponsor letting the tail wag the dog.
Last edited by Code Doc; Jan 25th, 2010 at 04:40 PM.
Doctor Ed
-
Jan 25th, 2010, 04:27 PM
#13
Thread Starter
Lively Member
Re: How do I creat a line of buttons?
Hi All!
First of all, Thanks U 4 all the answers!
I already have 4 OptionButton in the frame,
I add another 5 option buttons and one I press in one of them the other 4 previous button are affected.
I read that you write about it,
But I dont know how to solve it
What can I do?
How I add radio button visual effect and set the option button's Style property to Graphical then they will appear like command buttons, with a slight twist. ?
10X
Y
Last edited by li9erYol; Jan 25th, 2010 at 04:31 PM.
-
Jan 25th, 2010, 04:30 PM
#14
Re: How do I creat a line of buttons?
put the second set in a different frame, or better to use picture boxes as frames have issues with xp style buttons, and may be a problem later
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 25th, 2010, 04:33 PM
#15
Thread Starter
Lively Member
Re: How do I creat a line of buttons?
Can I do it in the same frame?
And if not,
How I add another frmae/form?
-
Jan 25th, 2010, 07:10 PM
#16
Re: How do I creat a line of buttons?
all radio buttons on a form or in the same frame are a single group, whether they are a control array or single controls
add a frame from the controls toolbox and make sure that the second set of radio buttons are in then moved into the new frame
or you can move controls into other containers (form, frames or pictureboxes), by code
set radio1.parent = frame2
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 25th, 2010, 07:25 PM
#17
Re: How do I creat a line of buttons?
 Originally Posted by westconn1
...set radio1.parent = frame2
Set radio1.Container = frame2, I believe
-
Jan 25th, 2010, 07:28 PM
#18
Re: How do I creat a line of buttons?
I like to add a real world analogies to CommandButtons vs OptionButtons. In the real world a CommandButton is roughly equivalent to a Push Button (Momentary) Switch. Unlike a momentary switch though, its Value=True property is True from the moment of the Click and remains True, until End Sub is executed. If you have code that takes 15 seconds to complete (in the Click Event), it will remain True for that period. Yeah, anal I know, but I tested this! 
On the other hand, OptionButtons are analogous to an array of mechanically interlinked locking push buttons, like the old auto radios had. Push any button and the one that was previously pressed pops out. A greater distinction though is its Value property, as it's Value remains True as long as it's the one that's selected, like a toggle switch remains closed until you switch it off.
Test setup for CommandButton's Value. Click Cmd1 to start the loop, then click Cmd2 to return its value while it's looping. It will return True until End Sub. When the loop finishes, click Cmd2 again. Cmd1 will return False.
Code:
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 20000 ' loop to kill time.
Me.Caption = i
DoEvents
Next i
End Sub
Private Sub Command2_Click()
MsgBox "Command1.Value = " & Command1.Value ' click while and after looping.
End Sub
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 25th, 2010, 07:50 PM
#19
Re: How do I creat a line of buttons?
Set radio1.Container = frame2, I believe
my bad
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 26th, 2010, 06:35 AM
#20
Thread Starter
Lively Member
Re: How do I creat a line of buttons?
Thanks for all the answers!
Another question,
Can I make a 5 square buttons that when the user clik on them, it seems like it pressed?
Thanks
Y
-
Jan 26th, 2010, 05:39 PM
#21
Re: How do I creat a line of buttons?
I have no idea what you're asking because if you set the OptionButton's Style to Graphical it's obvious when they're selected.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Jan 30th, 2010, 07:48 PM
#22
Re: How do I creat a line of buttons?
 Originally Posted by CDRIVE
I have no idea what you're asking because if you set the OptionButton's Style to Graphical it's obvious when they're selected.
That's why I elected not to respond to the question. OP must not even be looking at any executed code if he used a graphical button. Time to sign off and move on.
-
Jan 31st, 2010, 10:19 AM
#23
Re: How do I creat a line of buttons?
 Originally Posted by CDRIVE
I have no idea what you're asking because if you set the OptionButton's Style to Graphical it's obvious when they're selected.
Unless they are placed in a disabled frame/picturebox. Then they look normal, but won't be clickable.
li9erYol, you have us all guessing. I think it is best if you provide a very detailed explanation of how you set your buttons up, what controls you eventually used, and describe the frame properties that those buttons were placed in.
-
Jan 31st, 2010, 01:59 PM
#24
Re: How do I creat a line of buttons?
 Originally Posted by LaVolpe
li9erYol, you have us all guessing. I think it is best if you provide a very detailed explanation of how you set your buttons up, what controls you eventually used, and describe the frame properties that those buttons were placed in.
I suspect that what Dr. Ed said may apply here. If the OP doesn't follow instructions or run the code that's given they invariably ask questions like this. This is an experience tainted assumption, which could be totally wrong though. CYA
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
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
|