Vous êtes sur la page 1sur 4

Chapter-2

More VB Controls

Q1. What is the difference between an option button and a check box control?
Ans.
Option Button:
Option Button allows user to select one of several choices. Unlike
CheckBoxes,The user can select one and only one option button at a time.
After selecting one option button if the user click another option button.VB
deselect the previously selected option button and select the one the user click not that
option but is also called as Radio Button.
The common properties for option button contian are listed below:
a.Caption:
Contians the text, which appears next to the option button.
b.Alignment:
This property desides on which side of the text the option button will appear .You
can set this property to left Align or Right Align.
c.Name:
Identifies the name of the control.The prefix opt is use to name the control.
d.Picture:
If set property to 1-Graphical , you can use this property to display a picture
beside the option button instead of th3e in the caption property.
e.Style:
To display text besides option button set this 0-Standard and if you want to
display picture besides option button, set this property to 1- graphical.
f.Value:
This property can be set to true and false.When this property is set to true the
option button is selected by default only one option button in a group may set to true at
one time.

Check box:
Check box offers an option for the users. A checkbox might appear by itself or
perhaps along with several other checkboxes.
The checkbox , when click , display a checkMark which means user has
selected the checkbox option and the checkMark goes away when the user clicks the
checkbox once again.In short we say that a checkbox is a option on a form that is
checked when selected and unchecked when not selected.
This control is used when you want to offer the user two values choices,
such as whether someting is true or false the property , which determines the current
state of the checkbox , is the value property.
It the value property is 1 checkbox is selected and checkmark appears.If
the value is 0.Indicates checkbox is not selected and no checkmark appears.
The common properties for option button contian are listed below:
a.Alignment:
This property can be set to Left or Right Align.
b.Caption:
Set there property to the value you want to use to refer to the control in
your code.
c.Name:
Set there property to the value you want to use to refer to refer to the
control in your code. The prefix is chk.
d.Style:
To display text beside textbox,set these property to 0-Standard to display
picture beside checkbox set the property one graphical.
e.Picture:
This property can be set to bitmap,GIF,JPEG file.For this you must set
the style property to 1-graphical.
f.Value:
This property may be in one of the following 3 state :
0- Unchecked - Means that no checkmark appears in the checkbox.
1- Checked-Means that this item has been selected and checkmark
appears in the checkbox.
2-Grayed-Means checkbox is not available at this time.

Q.2 How can you make groups of option buttons?Explain.( 8 mrks )


Ans.
Option Button:
Option Button allows user to select one of several choices. Unlike
CheckBoxes,The user can select one and only one option button at a time.
After selecting one option button if the user click another option button.VB
deselect the previously selected option button and select the one the user click not that
option but is also called as Radio Button.
The common properties for option button contian are listed below:
a.Caption:
Contians the text, which appears next to the option button.
b.Alignment:
This property desides on which side of the text the option button will appear .You
can set this property to left Align or Right Align.
c.Name:
Identifies the name of the control.The prefix opt is use to name the control.
d.Picture:
If set property to 1-Graphical , you can use this property to display a picture
beside the option button instead of th3e in the caption property.
e.Style:
To display text besides option button set this 0-Standard and if you want to
display picture besides option button, set this property to 1- graphical.
f.Value:
This property can be set to true and false.When this property is set to true the
option button is selected by default only one option button in a group may set to true at
one time.

Q.3 What do you mean by access keys?Why are they used ?( 4 mrks )
Ans.
You can make your project respond through the keyboard by defining access
keys you can set access keys for command buttons, option buttons and check boxes
when you define their caption properties.Type an ampersand '&' in front of the character
you want for the access keys VB underlines the character.
Example:
&ok for Alt +o
&Exit for Alt+E
Q.4 What is a tooltip ? How can you make it to appear ?( 4 mrks )
Ans.
If you are a windows use,you probably appreciate and rely on ToolTips,those
small labels that pop up when you pause your pointer over a toolbar button or
control.You can easily add ToolTips to your projects by setting the ToolTip Text property
of any control that you want to display a ToolTip.
To define a ToolTip for a command button, add a new command button to a
form .Change the button's Caption property to Exit and set its ToolTipText Property to
"Close and Exit the program ".Now run the project , point to the Exit button , and pause ;
the ToolTip will appear.

Q.5 Explain With block with an example. ( 8 mrks )


Ans.
With. . . . . End With:
This is a constrict provided by VB , which is used in the case were
we are operating on one object.
Example:
We are setting multiple properties for one object.
For Example,consider following code wile setting the various properties of
Form1.object.
Form1.Top = 0
Form2.Left = 0
Form1.windowState = vbMaxmized
Form1.show
So, instead of writing Form1 again and again in above vb statement.We can also
do this using With. . . . End With constrict is as follows:
With Form1.
. Top=0
. Left=0
. Window state = vbMaximized
. show
End With

Q.6 What is a purpose of image control and how can it be created ? ( 6 mrks )
Ans.
image control:
An image control hols a picture.Youcan set an image picture property to
file with an extension of .bmp,.GIF, .JPEG etc.
First place the image control on a form and than select its picture property
in the properties window.Click on the propertis button to display load picture dialog bpx
were you can select a filename.
You can use any picture file ( with the property format ) that you have
available.
Set the Stretch property of image control to true to make the picture
enlarge to filled the control .You can set the visible property to false to make the image
disappear.The letter prefix for naming an image is img.
For Example,to make an image invisible at run time , use this code statement:

imgLogo . Visible = False


Q.7 What is conctenation and when can it be used ?( 4 mrks )
Ans.
All times you need to join strings of text.For example , you may want to join a
literal and a property . You can "tack " one string of characters to the end of another in
the process called concatenation.Use an ampersand (&) , preceded and followed by a
space , between the two strings.
Examples:
lblMessage.Caption = "Your name is : " & txtName.Text
txtNameAndAddress.Text = txtName.Text & txtAddress.Text

Q 8. What is the Continuation operator ? When is it used ?( 4 mrks )


Ans.
When a Basic statement become too long for one line , use a line-Continuation
character.You can type a space and an underscore , press Enter, and continue the
statement on the next line . It is OK to indent the continued lines.The only restriction is
that the line-continuation character must appear between elements; you cannot place a
continuation in the middle of a literal or split the name of an object or property.
Example:
lblGreetings.Caption = " Greetings " & txtName.Text & " : " & " You have been
selected to win a free prize."

Vous aimerez peut-être aussi