View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Dale Fye Dale Fye is offline
external usenet poster
 
Posts: 169
Default Groups in Option buttons

For now, I've written 2 routines that allow me to perform this function.

Now, all I have to do is call the function to get the value of the obtion
button that is selected (assumes values of 1 to N) for the buttons, returns a
zero if not selected. Same for setting the values.


Public Function GetFrameValue(og As Frame) as integer

Dim intPointer As Integer

GetFrameValue = 0
For intPointer = 0 To og.Controls.Count - 1
If og.Controls(intPointer) = True Then
GetFrameValue = intPointer + 1
End If
Next

End Function
Public Sub SetFrameValue(og As Frame, SomeValue As Integer)

Dim intPointer As Integer

For intPointer = 0 To og.Controls.Count - 1
og.Controls(intPointer) = (intPointer = SomeValue - 1)
Next

End Sub

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Dale Fye" wrote:

Similar issue.

I have a frame (vb toolbox) on a UserForm. Have two OptionButtons in the
frame.

In Access, each of the option buttons would have a numeric value, and I
would refer to the frames value to determine which OptionButton was selected,
and to set them via code.

Is there a simple way to do this in Excel? I've got several more of these
and would like a quick and easy way to determine which is selected and to set
them via code.

Dale
--

email address is invalid
Please reply to newsgroup only.



"Rick Rothstein (MVP - VB)" wrote:

Where did your OptionButtons, GroupBox and TextBox come from (the Visual
Basic or Forms Toolbar; or, perhaps, you are using a UserForm)? I ask
because the Forms' Toolbar has a GroupBox but no TextBox whereas the Visual
Basic Toolbar calls its "group box" a Frame and does have a TextBox. Or are
you mixing components from both Toolbars?

Rick


"Greg B" wrote in message
...
Yeah I didn't make much sence sorry, I have a group of 7 optionbuttons in
a group called "expenses".
Instead of going throught all with the code for each individual optionbox,
I was wondering if there was a way to have the selected box put it's
caption into a textbox called reason.

Hope that is a bit more understandable.

Thanks Again
Greg
"Peter T" <peter_t@discussions wrote in message
...
Hi Greg,

Is that Option buttons on a form to which you have assigned a GroupName
property,
or
Forms OB's on a sheet, which you have Grouped or placed in a GroupBox
Or
ActiveX OB's on a Sheet which you have done either of the above or given
GroupNames

After clarifying the above, explain that you mean by -

"I am looking to have reason.text show the answer."

What is "reason", what do you have in mind for the "answer"

Regards,
Peter T


"Greg B" wrote in message
...
I would like to know how I can get the data from a group of option
buttons.
I have a group of 8 optionbuttons with the names "e1" through to "e8",
the
name of the group is "expenses" I am not sure how to use or if I can
use
a
groupname vba. I am looking to have reason.text show the answer.
Or do I have to go through and write if e1.value = true then.....

thanks in advance

Greg