Solved

Using Option buttons

Posted on 1998-08-18
3
144 Views
Last Modified: 2010-04-30
every time i use a option button in a calculation program i get -1 in the answer box
0
Comment
Question by:kelly1
3 Comments
 
LVL 1

Expert Comment

by:Sekans
Comment Utility
What is the code you're using?  -1 is the same as True (or more accurately Not False)  Please ellaborate on your question.

Regards,
Sekans
0
 
LVL 6

Accepted Solution

by:
anthonyc earned 50 total points
Comment Utility
Kelly,

You are using the option button value, which is true/false value.  You want to use the index of the option button that is marked as true.  To do this, make your option button group a control array, and set the indexes to the value you want.  To get the integer value representation of the option button, do this

public function OptionButtonValue(optgrp as object, optional nDefault as integer = -1) as integer
  dim opt as optionbutton

  optionbuttonvalue = nDefault
  for each opt in optgrp
    if opt.value then
      optionbuttonvalue = opt.index
      exit function
    end if
  next opt
end function

0
 

Expert Comment

by:dkaratzios
Comment Utility
Hi kelly1,

Have you tried putting your calculations in variables ? This way, you only use your option buttons to indicate which variable to want in your calculations?

ex:
dim opt_var as long
opt_var = any number for calculation

if optionbutton is true then
opt_var * whatever
end if

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now