Sei sulla pagina 1di 18

Search

Visual Basic 6 (VB6)


Home Tutorials

RSS: Site Feed

Option

VB Tutorial

Push Button

Database

Using Option Buttons aka Radio Buttons

Twitter: Visual Basic


Facebook: Visual Basic

Visual Basic 6.0


VB Net Applications
VB Code

Navigate To
Home
Tutorials
Source Code Samples
VB.NET Tutorials

Level:

Mathcad Prime 2.0 Sverige


www.alfasoft.com
Den globala standarden fr matematiska berkningar
Written By TheVBProgramer.

Option buttons, also called radio buttons, are typically used in a


group of two or more. At any one time, only one button in the group
can be "on". Clicking an option button turns it "on" and turns all
other buttons in the group "off".

Add Your Tutorial


Forums
Articles
External Links
Advertise Here!
Contact Us

Guides
Beginner Guide
Controls Guide
Understanding forms
Timer control
Multiple Forms
Everything Images
Control arrays

Option button groups operate in a container control, such as a


frame. Therefore, different sets of option button groups should be
placed in their own frame on the form. Recall how to place a control
directly inside a frame: either (1) single click it from the toolbox and
draw it in, or (2) double-click it from the toolbox, cut it from the form,
and paste it into the frame. If a group of option buttons is not
contained within a frame, then the form itself acts as their container.
In code, to perform an action based on which option button the user
clicked, do one of two things:
(1) To perform an action as soon as the user clicks an option button,
place code in the Click event of the option button.
(2)
To perform a "delayed" action, such as when the user clicks
a command button, check the Value property of the option
buttons in the group. If the Value = True, then the button is
"on".

Option Buttons
Check Boxes
Math Game
(o) Hangman
(o) Tic Tac Toe
(o) Calculator
(o) Cryptogram
(o) Concentration

Examples using both methods follow. (Note: The examples in this


topic use the built-in color constants vbRed, vbGreen, and
vbBlue. More information on color constants is provided in the
section at the end of this topic.)
First, a frame containing three option buttons, named optRed,
optGreen, and optBlue respectively was placed on the form shown
below:

Database Guide

User login
Username: *

Password: *

Log in
Create new account
Request new password

Next, code was written for the Click event of each of the option
buttons. The code causes the background color of the form to
change to the appropriate color when one of the option buttons is
clicked:
Private Sub optRed_Click()
Form1.BackColor = vbRed

End Sub
Private Sub optGreen_Click()
Form1.BackColor = vbGreen
End Sub
Private Sub optBlue_Click()
Form1.BackColor = vbBlue
End Sub
If the program was to be run at this point, you would get immediate
results when you clicked one of the option buttons as soon as
you clicked one of the option buttons, the form would change color.
To demonstrate the "delayed" action, let's say the above program
was modified as follows: First, a command button named
cmdChangeColor is placed on the form:

Second, all code from the option buttons' Click event (shown in the
previous example above) is removed.
Third, code for the cmdChangeColor_Click event is written as
follows:
Private Sub cmdChangeColor_Click()
If optRed.Value = True Then
Form1.BackColor = vbRed
ElseIf optGreen.Value = True Then
Form1.BackColor = vbGreen
Else
Form1.BackColor = vbBlue
End If
End Sub
If the program was to be run at this point, clicking on one of the
option buttons would not cause an immediate result it would
simply set the Value of the clicked button to True. Only when you
clicked the "Change Color" button would the background color of
the form change, based on the code above.
Syntax Notes:
The Value property is the default property of the option button and
can therefore be dropped when coding, as in:
If optRed = True Then . . .
Since Value is a Boolean property, you can drop the "= True" from
the conditional expression, making it possible to cut the coding
down further to:
If optRed Then . . .
Coding an Option Button Control Array
Using the same scenarios as in the examples above, suppose we
used a control array for the set of three option buttons (a control

array called optColor indexed 0 through 2 instead of the individual


buttons optRed, optGreen, and optBlue).
The coding for the "immediate" action (using the option button's
click event) would be:
Private Sub optColor_Click(Index As
Integer)
Select Case Index
Case 0
Form1.BackColor = vbRed
Case 1
Form1.BackColor = vbGreen
Case 2 ' could also use "Case Else"
here
Form1.BackColor = vbBlue
End Select
End Sub
The coding for the "delayed" action (using a command button)
would be:
Private Sub cmdChangeColor_Click()
Dim intLoopCtr As Integer
Dim intIndex As Integer
For intLoopCtr = 0 To 2
If optColor(intLoopCtr).Value = True
Then
intIndex = intLoopCtr
Exit For
End If
Next
Select Case intIndex
Case 0
Form1.BackColor = vbRed
Case 1
Form1.BackColor = vbGreen
Case 2 ' could also use "Case Else"
here
Form1.BackColor = vbBlue
End Select
End Sub

The sample program exercises each of the scenarios discussed


above. A screen shot is shown below:

Download the VB project code for the example above here.


Color Constants
VB provides a set of built-in constants that can be used to refer to
colors. Some of these were used in the sample program presented
in this topic. The available constants, from MSDN, are listed below:
Colors
Constant
vbBlack
vbRed
vbGreen
vbYellow
vbBlue
vbMagenta
vbCyan
vbWhite

Value
&H0
&HFF
&HFF00
&HFFFF
&HFF0000
&HFF00FF
&HFFFF00
&HFFFFFF

Description
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White

System Colors
Constant
vbScrollBars
vbDesktop
vbActiveTitleBar

Value
&H80000000
&H80000001
&H80000002

vbInactiveTitleBar

&H80000003

vbMenuBar

&H80000004

vbWindowBackground

&H80000005

vbWindowFrame

&H80000006

vbMenuText

&H80000007

vbWindowText

&H80000008

vbTitleBarText

&H80000009

vbActiveBorder

&H8000000A

vbInactiveBorder

&H8000000B

vbApplicationWorkspace

&H8000000C

vbHighlight

&H8000000D

vbHighlightText

&H8000000E

vbButtonFace

&H8000000F

vbButtonShadow

&H80000010

vbGrayText

&H80000011

Description
Scroll bar color
Desktop color
Color of the title bar
for the active
window
Color of the title bar
for the inactive
window
Menu background
color
Window
background color
Window frame
color
Color of text on
menus
Color of text in
windows
Color of text in
caption, size box,
and scroll arrow
Border color of
active window
Border color of
inactive window
Background color
of multipledocument interface
(MDI) applications
Background color
of items selected in
a control
Text color of items
selected in a
control
Color of shading on
the face of
command buttons
Color of shading on
the edge of
command buttons
Grayed (disabled)
text

vbButtonText

&H80000012

vbInactiveCaptionText

&H80000013

vb3DHighlight

&H80000014

vb3DDKShadow

&H80000015

vb3DLight

&H80000016

vb3DFace
vb3Dshadow

&H8000000F
&H80000010

vbInfoText

&H80000017

vbInfoBackground

&H80000018

Text color on push


buttons
Color of text in an
inactive caption
Highlight color for
3D display
elements
Darkest shadow
color for 3D display
elements
Second lightest of
the 3D colors after
vb3Dhighlight
Color of text face
Color of text
shadow
Color of text in
ToolTips
Background color
of ToolTips

Similar links
Database Access with the Data Control
Using ADO and the ListView control
Visual Basic Power Pack
SQL Databases Create, Update, and Query
VB6 Animated Charts (With FusionCharts)
VB6 Downloads
Common Dialogs Allow A professional VB app
Using Toolbars in Visual Basic Tutorial
Working with Menus in VB6
Creating your own Drag and Drop apps in VB6

If you enjoyed this post, subscribe for updates (it's free)


Email Address...

Multiples Choices using Radio


Buttons

Subscribe

Sun, 10/14/2012 - 19:59 Simon (not verified)

How do you choose multiple choices using radio buttons?


reply

option button

Sun, 10/14/2012 - 08:06 pinnie (not verified)

What is the code for inserting a color e.g green in an option button such that when you
click on the button,the color changes into green instead of remaining black.
reply

Radio Button

Mon, 02/06/2012 - 19:59 Anonymous (not verified)

If you have created a calculator and have used radio buttons such as "Calculate" and
"Exit". How do I create the operator in order to be able to use the button?
reply

Re order options control

Wed, 02/01/2012 - 08:42 Anonymous (not verified)

I have 10 option controls refer to a cell, result a number of which option selected.
I want to reorder this option control, but how?
Thanks for your help
reply

Radio buttons

Sun, 03/11/2012 - 17:29 Rich (not verified)

I have to put together an evaluation instrument using Word 2007. I am not a code
specialist, so can you help me write code for the buttons?
example
1. Employee is punctual 4 3 2 1 0
2. Employee is professional 4 3 2 1 0
3. Employee is courteous 4 3 2 1 0
Each numeric option needs to correspond to a radio button and I will need to create
this in chart form.
If you could help me with this code, I think I could copy/paste/modify to complete all
sections of the survey.
Any time and assistance that you can give me will be very much appreciated.
Thank you,
Rich
reply

Option if then

Fri, 01/27/2012 - 12:07 djmetelex (not verified)

Hi, i need to know how could i code for an if then with an option and a textbox!
What i want? Code or ideas for code to do this:
if opt1.enabled = true then opt2.enabled = false
if opt1.enabled = True then txt1.text = "V-"
I try it on VB6 but the syntax is invalid, second, i need in the textbox after V- appears the
cursor but it disappear, how can i get the cursor right after opt1 is selected it appears
after text V- in the textbox??
and last, i have a combobox, i put the list and locked is false, how can i capture what i
select from the list in my databse?
Im a beginner and i have to do this for my class!!
reply

haii!! im an IT student ..

Wed, 01/11/2012 - 18:12 Vapor (not verified)

haii!! im an IT student .. could someone please help me do some coding about a voting
system ?? i badly need ur help

reply

Pizza Ordering Machine

Wed, 10/26/2011 - 23:31 Ariel (not verified)

there are 5 group box in each group box there are 5 check box and each of them has a
equivalent value if ordered. How can i create a code for those ones. Example: 1st
groupbox i chose button 3 which is equivalent to $500 then in groupbox2 i checked
button 1 which is equivalent to $900 and last Groupbox3 i checked button 5 which is
equivalent to $50. What will i put to compute button to input in the textbox1 the total
amount of charge.
reply

helppp!

Tue, 10/18/2011 - 17:56 HELPPP:| (not verified)

Hey there! I am new to visual studio, and i have a project that is due and i need help to
get it started i have some coding and can get the insults to the message box but that is it.
1. The interface must include:
A textbox for the user to enter the name of the victim
A control that allows the user to select the number of adjectives to be included in the
insult (1-3)
A button to generate the insult
An output textbox where the insult will be displayed to the user
A button to clear the application so you can generate new insults with a new victim
A button that will display about information in a popup
2. The output textbox should display all insults generated, separated by a carriage
return; every time the user clicks the generate button a new insult is added to the textbox
3. An error message box should appear if the user tries to generate insults without
entering a victim's name first and not produce an insult as a result
4. The generator must randomly select each adjective and the single noun from a
possible set of adjectives and nouns; there must be at least 10 possible adjectives and 6
possible nouns; repeated adjectives are allowed
5. After randomly selecting the adjectives and noun, the generator then builds an insult
including the victim's name entered and displays in the output textbox. Every newly
generated insult must be displayed at the top of the textbox not the bottom!
6. This application must include some custom visual design (size, button size, fonts, form
icons, colors, etc) as well as be user-friendly!
7. All controls must be logically named
8. You should not have any large blocks of code that are repeated. This is known as
redundant code...however, handling multiple insult adjectives in this project tends to take
beginners down this route. Can you use loops to avoid this?
9. In the past, some students have explored Arrays when developing a solution for this
project. Although they do provide an efficient solution to the problem, this project
requires that NO ARRAYS are used.
this is the information! i got the form all layed out and trying to get the victims to go with
the radio button, but when i do that and typ my victim in and click the radio button only
the insults show up..
reply

Push button - Set commands

Tue, 10/11/2011 - 08:50 Infinitelimit (not verified)

Hi,
Can anyone help me with setting up a push button to create and execute a push button
that replaces old values with new values.
Example:
Old New
2.5 3.0
1.5 3.5
2.0 2.5
Then RESET button pressed.
Old New
3.0

3.5
2.5
So then, I can enter the new values.
Thanking you in advance for your time.
reply

help!!

Thu, 09/01/2011 - 17:37 Becca (not verified)

how can I do option button works?? because I use the code but is failed,I don't know :S
reply

Do what....

Fri, 09/02/2011 - 11:45 ChrisGT7

What exactly do you want to do with the option button?


My e-mail is: chrzgt7@hotmail.com. Send me any questions there.
ChrisGT7
reply

how do i display the option

Mon, 04/11/2011 - 06:17 Anonymous (not verified)

how do i display the option in the data report??


reply

How to insert radio button


value into mysql database

Sun, 03/20/2011 - 02:11 Anonymous (not verified)

for example:
if user are check in..
> click radio button and system will save the time when are the user check in..same goes
to the check out method..
anyone out there..can you help me..
reply

hellow world

Fri, 03/11/2011 - 23:44 Elvin (not verified)

ahm.. i would like ask some vb codes about option button..and check button connecting
to database..if you can help me pls.. send me some example codes for that..tnx
reply

HI!!!

Wed, 03/02/2011 - 11:23 Carla (not verified)

Can anyone tell me how to fix this problem I have with my Radio Button: rad = radio btn =
button
Dim txtNameEmp, txtworkdone, radbtnJ, radbtnA, radbtnT As String
Dim txtHours, lblPay As Double
If radbtnJ = True Then
lblPay = txtHour * 12 (<- Money they are suppose to earn for each hour)
ElseIf radbtnA = True Then
lblPay = txtHours * 10
ElseIf radbtnT = True Then
lblPay = txtHours * 8
End If
End Sub
I need to calculate how much an employee will earn if he works as: "J" = Permanent

worker $12, "A" = apprentice workers $10 and "T" = Temporary workers $8. I putted the 3
radio buttons in a Panel (container) and kept trying to figure out what is the problem here
but I don"t know... It keeps saying: "Variable 'radbtnJ' is used before it has been assigned
a value. A null reference exception could result at runtime" Can anyone help please!!!
reply

Variables

Wed, 03/02/2011 - 14:17 ChrisGT7

I believe the problem is at the way you have declared your variables.
You have only declared the "radbtny" as string and lblPay as Double. All the rest
variables have been declared as variant and the program doesn't know what type is
going to be used for. So when you try the "If radbtnJ = True Then" is a run-time error
because the variable radbtnJ is empty and it hasn't been assigned any value to it
yet.
Try this instead:
Dim txtNameEmp as String, txtworkdone as String, radbtnJ as String, radbtnA as
String, radbtnT As String
Dim txtHours as Double, lblPay As Double
I hope I helped you!
reply

option and checkbox w/


images

Sun, 02/27/2011 - 02:16 Anonymous (not verified)

how can a make a program wherein there are 5 option buttons w/ diffrent pictures each
behind it, and when i click 1 opt button the picture behind it will appear and so on.. pls
answer.. tnxmuch.. and give me also the codes..
reply

Code for Option buttons

Mon, 02/28/2011 - 12:30 ChrisGT7

Two control arrays (one with 5 option buttons and one more with 5 images) will help
you enough.
Here is what I have in mind:
Private Sub Option1_Click(Index As Integer)
for I = 0 to 4
Image1(I).visible = iif(I <> Index, False, True)
next
End Sub
If you need anything else, please tell me!
reply

hey!

Wed, 03/02/2011 - 11:28 Carla (not verified)

Can you help me with my problem please! I posted it under my name Carla ...
It seems like you could really help!!
reply

hey guys, I have a problem

Thu, 01/27/2011 - 00:11 Anonymous (not verified)

hey guys,
I have a problem in visual basic about in pizza ordering system
Can you send me a codes ..
Please reply ..

reply

check box...

Thu, 01/20/2011 - 23:05 Anonymous (not verified)

hey...
v are making a project name quiz....
v are making a form in which v are providing 8 check boxes for options to the question...
my query is...if user select any check how v store d value of check box and which text box
user select it
displayed on text box...that user selects option no1,2,3 like that...
please send me the code....
reply

Use a control array

Sat, 02/19/2011 - 13:12 ChrisGT7

You should make an array of checkboxes. Here is what you have to do:
Create a checkbox, copy it and paste it. Answer yes to the question so VB can make
an array of checkboxes. Paste it as many times as you need. Place them at the order
you want. After this, go and correct the Index property of each checkbox. This is the
value you need. Double click any checkbox and the code should be something like
this:
Private Sub Check1_Click(Index As Integer)
If Check1(Index).Value Then Text1.Text = Index
End Sub
reply

Option Button Matrix 2 x 4

Sat, 10/23/2010 - 13:28 Dan Nickell (not verified)

I am trying to develop a program that begins with a questionnaire with a set of 24


question. For each question, there are four option descriptors. The person answering the
questionnaire is supposed to indicate which option Best describes him/her and which
option Least describes him/her. For example:
Best Least Description
___ ___ Fair, just
___ ___ Pretty/Handsome
___ ___ Rich and Wealthy
___ ___ Liked and Admired
I want to use Option Buttons in this 2 x 4 array. Only one button can be 1 (true) in either of
the vertical columns and only one be 1 (true) in any of the rows, although both buttons
can be 0 (false) in any two of the rows. I can construct the matrix that works on the Row
level, but not the Column level...or vice versa, but not both rows AND columns at the
same time.
Any ideas?
reply

check box...

Sat, 10/09/2010 - 06:32 suman kumar (not verified)

hey...
v are making a project name movie ticket booking....
v are making a form in which v are providing 140 check boxes for selecting the seat...
question is...if user select any check how v store d value of check box and which text box
user select it
displayed on text box...that user select seat no1,2,3 like tha...
plese send me the code....
reply

Sun, 10/03/2010 - 08:01 Anonymous (not verified)


Savesettings and
getsettings with options buttons

please i need a code on how to use the savesettings and getsettings, with option buttons
i need it seriously for an upcoming test, please help me out
reply

vb10

Sat, 10/02/2010 - 02:22 DS (not verified)

hey i hv vb 10..
i m doin a projct on hospital mangmnt in vb..i hv created forms as per my design of front
end...i hv created database in vb 10 only wich is available...the problm is dat wen i run
the form,and insert values and save dem,dey donot get actuly saved in d database...in
short how to connect my database to my values...i hav add ,del ,edit ,save buttons on
forms rest all labels n text boxes..the four buttons are not helpn me in connectng my
database,pls help
reply

using operation

Tue, 09/28/2010 - 18:56 Anonymous (not verified)

hello i just want to learn option button using the operation please help me to know that...
reply

option button

Fri, 08/27/2010 - 01:20 kevinolivera

olivera
how to select 2 option button in 1 form??
expamle
i got 5 option button .. i want to select 2 or 3... how to do this??
reply

option button

Wed, 12/01/2010 - 21:47 Anonymous (not verified)

Use check boxes -- the user can make multiple selections; don't use option buttons
since the user can only make one selection
reply

you can..

Sat, 09/18/2010 - 15:54 budzy (not verified)

use frames for your option buttons.


reply

i think you cant do

Sun, 09/12/2010 - 20:04 Anonymous (not verified)

i think you cant do that...why not use checkboxes for that? ^_^
reply

It cancels my form

Thu, 05/06/2010 - 12:12 moon the look (not verified)

I'm using the radio controls to select either player one or two for a score board.
When im using the code Total1 = 1 + Total1 and run the program, it ends my form.
RadioButton1.Checked = True
TextBox4.Text = Total1

On the button Total1 is my integer and when the radiobutton1 is selected i wanted the
counter "1" to be displayed in text box 4 but it just close's everything down and dosen't
show any error's.
Is there a tutoral i could look at or any idea's round this?
reply

how can i count all the

Sat, 04/24/2010 - 16:13 dong (not verified)

how can i count all the radio buttons that are checked? please reply asap.
reply

ho to select option buttons

Thu, 01/28/2010 - 13:49 Pratikkr (not verified)

hi , in my form i have three frames each containing some option buttons, by default i have
to keep the fist option clicked(value="true") in each frame, but when i put the value say
option1 in fram1 as TRUE and then put value say option6 in frame2 as TRUE then the
1st one becomes False, when i put again TRUE for value in next optionbutton in fram3
this second one becomes false.
Please suggest how to keep one option in each fram selected at one time(By Default
Option.Value should be TRUE for first option Button in each frame.).
reply

Options buttons & IF


FUNCTION

Thu, 01/21/2010 - 09:18 Anonymous (not verified)

Anyone know how to use an option button in conjunction with an if funciton.


Here is the scenario...
Column A = Option button 1 (TRUE)
Column B = Option buttion 2 (FALSE)
Column C = If function, where if column A is True, then ....."output"
I've already ensured the T/F option buttons are in their own groups but now when i write
my logical test, i dont get back the proper results..Any thoughts?
reply

if it's two groups

Mon, 12/07/2009 - 03:10 anonymous (not verified)

spouses I've got 2 group of RadioButton how i can connect between them i mean by
using (IF .. Then)
For example If RadioButton1 & RadioButton2 = true then (blah...blah)
reply

Put your radiobuttons


into 2

Wed, 09/01/2010 - 10:17 Sergio Siqueira (not verified)

Put your radiobuttons into 2 different Frames.


reply

Check box and option button


I write a VB program like this:
here is check box
here is option button1
here is option button2
here is option button3

Thu, 09/10/2009 - 02:13 elmer (not verified)

Supposed to be, when i click the checkbox, the 3 option button should be in true value,
meaning all 3 have dot value. the problem is
only the 3rd option button has the true value. Can you give me the program of this one.
just send your replay to my email address. Thanks
reply

Value not valid

Thu, 08/27/2009 - 02:46 jyothihs (not verified)

I am writing a program where there are 10 option buttons.


When I give if optionbutton1.value then
Msgbox "blah blah "
elseif optionbutton2.value then
Msgbox "blah"
end if
it is coming invalid function or variable.
Pls help me in this. pls
reply

Value not valid

Wed, 12/01/2010 - 21:57 Anonymous (not verified)

Try this:
If OptionButton1.Value = True Then
MsgBox "You chose Option 1"
ElseIf OptionButton2.Value = True Then
MsgBox "You chose Option 2"
End If
reply

option button

Wed, 09/01/2010 - 23:46 Anonymous (not verified)

you must specify if it is true or false. ex. me.option1.value = True


reply

try, if optionbutton1.value

Fri, 08/28/2009 - 01:30 chaitanya (not verified)

try,
if optionbutton1.value = true then
reply

option Botton

Tue, 06/09/2009 - 06:55 Ajith (not verified)

This is good artical.I get lot of things about op. botton.Thanks .Wish U all the best
reply

thx

Thu, 05/21/2009 - 11:27 Anonymous (not verified)

Thanks! I couldn't figure out how to use these "radio buttons" before I read this tutorial! I
used to think it was something like...
If Option1.Selected = True Then ...
LOL
reply

excellent!!!!

Tue, 03/24/2009 - 20:41 crista (not verified)

I Luv It!!!!!.......thanks for the resources!....


reply

How to write codes for a


search button.

Sat, 02/14/2009 - 07:25 OLURIN yinka (not verified)

How to write codes for a search button.


need ur assistance on how to programme a textbox and command button such that the
user will type in an existing name in a database and when the cmdbutton is clicked, the
name and record will be displayed
reply

Search button code

Thu, 11/18/2010 - 06:42 Anonymous (not verified)

Dim PassSQL As String


PassSQL = "SELECT*from Details WHERE[Name]like" & txtpassword.Text
mydetails.MoveFirst
Do Until mydetails.EOF 'Search untill the end of file records.
If txtpassword.Text = mydetails.Fields("Name") Then
Me.Hide
Form2.Show
Form2.txtname.Text = mydetails.Fields("Name")
Form2.txttel_no.Text = mydetails.Fields("Tel_no")
Form2.txtoccupation.Text = mydetails.Fields("Occupation")
Form2.txtresidence.Text = mydetails.Fields("Residence")
End Sub
Else
mydetails.MoveNext
End If
Loop
MsgBox("Invalid Name")
reply

Option buttons

Wed, 02/11/2009 - 04:06 Jake (not verified)

Im doing a game with option buttons, but an option button at the top left hand corner get
selected by default and stuffs it up. How do I stop that? Plz i relly need help!!
reply

Option button default

Thu, 02/12/2009 - 19:22 Jose Luis Vargas (not verified)

modify the option button property value = false. You can do it with all your option
buttons. To choose default, in declarations- general insert line with "option
button".value = true
reply

Very Helpful...

Tue, 02/03/2009 - 09:18 Mac

Wow, honestly, I never understood Radio buttons untill i just read that. I knew how they
worked, but I couldn't get them to work.
Thanks a lot for this explanation, it really helped me.
Mac --- 17 Years Old from NewYork.
Current Project - A TextBased RPG, One Player and Offline.
Completed Projects - 41.
Future Projects - Probably some simple games, such as Minesweeper, Memory games,
etc.
reply

vb Optionbox

Mon, 10/27/2008 - 18:00 Aly (not verified)

is it possible for me to connect a database using option box?


reply

radio button

Fri, 09/26/2008 - 07:20 Anonymous (not verified)

When the form loads, an option button gets selected by default? I don't want any of them
to be selected by default.....how do i do that?????
reply

answer

Sat, 11/08/2008 - 10:31 Anonymous (not verified)

i think u can set the option button enable propity to false then it will not be selected :)
reply

option buttons

Mon, 09/08/2008 - 10:24 Anonymous (not verified)

how can i add an option buttons in a different groups wherein in that different group of
option buttons is i can choose one option in that particular group and also i can choose
another option in a different group.... how to do this in visual basic????
reply

Option button by
groups

Thu, 02/12/2009 - 19:37 Jose Luis Vargas (not verified)

Step 1. Create a container control (like a frame) inserted in your form.


Step 2. create one or more option buttons INSIDE a frame (or container control)
clicking over the frame.
To create another group, follow the same steps.
For each container control, with several option buttons, only activated one at time.
reply

Null

Wed, 06/06/2007 - 10:28 Anonymous

If no button is pushed for an option button, is it given a "null" value?


reply

How can an option button be

Sat, 06/02/2007 - 15:31 Anonymous

How can an option button be made to work in an excel spreadsheet, this code does not
perform the function for me. any HELP?
reply

Excel and radio buttons

Wed, 07/01/2009 - 15:51 Jamesinsocal (not verified)

Just today I found a method to use radio buttons to plug values into excel cells.
I used the cell method.
For an example, create four radio buttons and make sure they are in the same
group. Then code:

Private Sub OptionButton1_Click()


Cells(1, 1) = 1
End Sub
Private Sub OptionButton2_Click()
Cells(1, 1) = 2
End Sub
Private Sub OptionButton3_Click()
Cells(1, 1) = 3
End Sub
Private Sub OptionButton4_Click()
Cells(1, 1) = 4
End Sub
Clicking each button changes the value in cell a1 aka...$a$1, and (1,1)
That should get you started.
James
reply

Trying to set an option

Sat, 06/02/2007 - 15:29 Anonymous

Trying to set an option button for a YES and No option. can't simply relate the code to
this.. any HELP?
reply

Setting an option

Wed, 01/23/2008 - 05:20 Anonymous

For you to set a no and a yes option you use the if statement and on the form there
must be two option boxes. For example if you have one of the option boxes as
optyes and the other as optno. Double click the two option boxes eg if you click the
yes option box the code will be as follow
if optyes.value = 1 then
here you write what you want to be displayed when the yes option box is clicked.
else
here you write what you want to be displayed if the yes option box is not clicked.
end if
You also do the same for the No option box only this time you replace the yes word
with no
I hope i've helped.
reply

how to revert back to default settings

Tue, 04/10/2007 - 04:26 Anonymous

suppose if i change the background to red and want to change back to the previous
default setting then what i have to do..
reply

Reverting back to default setting

Wed, 01/23/2008 - 05:05 Anonymous

you first need a command button after clicking on the new command button in the
code section write
BackColor=vbButtonFace
reply

What about default settings?

Wed, 03/28/2007 - 09:16 Anonymous

Okay as far as it goes, but it doesn't say anything about how to set one of a set of buttons
as the default (i.e. that which is selected when a program starts. That looks like pretty
basic information to me, yet I can't find anything about it here!

reply

Okay as far as it goes, but

Sat, 02/23/2008 - 12:39 Anonymous

Okay as far as it goes, but it doesn't say anything about how to set one of a set of
buttons as the default (i.e. that which is selected when a program starts. That looks
like pretty basic information to me, yet I can't find anything about it here!
The TabIndex property decides order the objects are selected in the form. You can
see this, when the user press the Tab key. That means, the object with the TabIndex
set to 0 will be the "default" selected. You can either assign the 0 TabIndex to
another object (like a CommandButton or a TextBox) or to a new object and hide it
(Visible property set to False).
reply

After reading this tutorial

Fri, 03/02/2007 - 04:27 Anonymous

After reading this tutorial i learnt how option buttons using control arrays work for
delayed action ie via a command button which i failed to do earlier. This tutorial taught
that extra to me excellently.
reply

Post new comment


Your name:
Anonymous
E-mail:
The content of this field is kept private and will not be shown publicly.

Homepage:

Subject:

Comment: *

Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
Lines and paragraphs break automatically.
You can enable syntax highlighting of source code with the following tags: <code>,
<blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options


Word verification: *

(verify using audio)


Type the characters you see in the picture above; if you can't read them, submit the form and a new
image will be generated. Not case sensitive.

Preview

MS Access VB Code
OpenGateSw.net/UI-Builder
Web 2.0 Menu Look & Feel in MS Access, Free Demo!
Unless otherwise noted, all content on this site and in the source samples is Copyrighted
2011 by the owner of vb6.us. All rights reserved - Contact Information

Potrebbero piacerti anche