• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Using Option buttons

every time i use a option button in a calculation program i get -1 in the answer box
1 Solution
What is the code you're using?  -1 is the same as True (or more accurately Not False)  Please ellaborate on your question.


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

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?

dim opt_var as long
opt_var = any number for calculation

if optionbutton is true then
opt_var * whatever
end if

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now