You are on page 1of 7

control tool category

INTRODUCTION

An object is a type of user interface element one creates on a Visual Basic form by
using a toolbox control. In fact, in Visual Basic, the form itself is an object. Every Visual
Basic control consists of three important elements:

Properties which describe the object,


Methods cause an object to do something and
Events are what happens when an object does something.

Control Properties

All the Visual Basic Objects can be moved, resized or customized by setting their properties.
A property is a value or characteristic held by a Visual Basic object, such as Caption or Fore
Color.

Properties can be set at design time by using the Properties window or at run time by using
statements in the program code.

Object. Property = Value

Where

Object is the name of the object one're customizing.


Property is the characteristic one want to change.
Value is the new property setting.

For example,

Form1.Caption = "Hello"

One can set any of the form properties using Properties Window. Most of the properties can
be set or read during application execution. One can refer to Microsoft documentation for a
complete list of properties associated with different controls and restrictions applied to them.

Control Methods

1
A method is a procedure created as a member of a class and they cause an object to do
something. Methods are used to access or manipulate the characteristics of an object or a
variable. There are mainly two categories of methods one will use in ones classes:

If one are using a control such as one of those provided by the Toolbox, one can call
any of its public methods. The requirements of such a method depend on the class
being used.
If none of the existing methods can perform ones desired task, one can add a method
to a class.

For example, the MessageBox control has a method named Show, which is called in the code
snippet below:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)

Handles Button1.Click

MessageBox.Show("Hello, World")

End Sub

End Class

Control Events

An event is a signal that informs an application that something important has occurred. For
example, when a user clicks a control on a form, the form can raise a Click event and call a
procedure that handles the event. There are various types of events associated with a Form
like click, double click, close, load, resize, etc.

Following is the default structure of a form Load event handler subroutine. One can see this
code by double clicking the code which will give one a complete list of the all events
associated with Form control:

2
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

'event handler code goes here

End Sub

Here, Handles MyBase.Load indicates that Form1_Load() subroutine handles Load event.
Similar way, one can check stub code for click, double click. If one want to initialize some
variables like properties, etc., then one will keep such code inside Form1_Load() subroutine.
Here, important point to note is the name of the event handler, which is by default
Form1_Load, but one can change this name based on ones naming convention one use in
ones application programming.

Basic Controls

VB.Net provides a huge variety of controls that help one to create rich user interface.
Functionalities of all these controls are defined in the respective control classes. The control
classes are defined in the System.Windows.Forms namespace. Data reports Visual Basic 6.0
can also be used to print reports from within Visual Basic 6.0 code with the help of data
custom control.

Text box

The text box is the standard control that is used to receive input from the user as well as
to display the input. It can handle string (text) and numeric data but not images or pictures.
String in a text box can be converted to a numeric data by the using the function value (text).
The following example illustrates a simple program that processes the inputs from the user.

Label box

The label is a very useful control for Visual Basic 6.0, as it is not only used to provide

3
instructions and guides to the users, it can also be used to display outputs. One of its most
important properties is caption. Using the syntax label caption, it can display text and
numeric data. One can change its caption in the properties window and also at runtime.

Command Button

The Command Button is a very important control as it is used to execute commands.


It displays an illusion that the button is pressed when the user click on it. The most common
event associate with the command button is the click event.

List box

The function of the List Box is to present a list of items where the user can click and
select the items from the list. In order to add items to the list, we can use the add Item
method.

Picture box

The picture box is one of the controls that is used to handle graphics. One can load
picture at design phase by clicking on the picture item in the properties window and select the
picture from the selected folder. One can also load the picture at runtime using the Load
picture method.

Image box

The image box is another control that images and pictures. It functions almost
identically to the picture box. However, there is one major in an image box is stretchable,
which means it can be resized. This feature is not available in the picture box. Similar to the
picture box, it can also use the load picture method to load the picture.

Combo box

4
The function of the combo box is also present a list of items where the user can click
and select the items from the list. However, the user needs to click on the small arrow head
on the right of the combo box to see to the items which are presented in a drop-down list. In
order to add items to the list, one can also use the add item method.

Categories of control tools

Visual Basic (VB) has two types of Controls: Intrinsic Controls and Active Controls. These
controls represent all the Graphics User Interfaces, as well as Operating Systems resources,
available to programmers.

Intrinsic Controls

There are 20 controls which are built in to VB. These controls are called intrinsic controls.
Every one of the intrinsic controls are available to every VB program one write. When one
create a "New" VB project, all 20 of the intrinsic controls will show up in the Toolbox. This
is true for all versions of VB.

ActiveX Controls

Microsoft uses this terminology to refer to any control which exists as a separate file whose
extension is OCX. To use an ActiveX control in ones VB program, the control must be
registered in the Windows Registry.

If one have a control which has not been registered by other software, one can register it
onesself using the free program provided by Microsoft. The program, REGSVR32, comes
with all version of Windows and is usually found in the Windows folder. To use it, simply
type in:

REGSVR32 control.ocx

where the "control.ocx" is the filename of the control that one want to register.

5
IDE and Controls

Here's a key point to remember. Just because one register a control does not mean that one
can use the control in one of ones projects. Registration only assures one that the control can
by used by an application at run-time. Whether or not a control can be used at design-time
(within the IDE) depends on the control.

There are many free controls which can be used freely at design-time. However, commercial
controls require that one install them using a password before one can use them within ones
project at design time. If one simply copy an OCX to ones system and register it with
REGSVR32, don't be surprised if one get an error message when one try to put the OCX on a
form!

Intrinsic Control List

The following list shows the 20 intrinsic controls that come with all version of VB. I have a
separate tutorial section to discuss them further:

checkbox frame OLE Container


combobox horizontal scrollbar optionbutton
commandbutton vertical scrollbar picturebox
data control image control shape control
dirlist label textbox
drivelist line timer
frame listbox

Sample ActiveX Control List

The next list shows some of the OCX controls.

Common Dialog CMDLG32.OCX automatically installed

6
DataComboBox MSDATLST.OCX automatically installed
DataList MSDATLST.OCX automatically installed
MSFlexGrid MSFLXGRD.OCX automatically installed

CONCLUSION

Database controls make database access very easy for programmers to utilize
existing databases in their applications. Remember that there are a variety of database
products on the market, and that many vendors have their own proprietary formats in which
the data is stored. In the case of Microsoft's Access database program, the method of
accessing the database is through software which Microsoft calls its Jet Database Engine.
Other vendors have their own access methods. he first method VB offered for using ODBC to
create/edit databases was DAO. Microsoft is in the process of replacing the ADO/RDO
features with the newer ADO. VB provides two controls which makes the link to the database
file and which creates the recordset that is exposed to the rest of the controls in the
application.

REFERENCES

https://msdn.microsoft.com/en-us/library/aa733708%28v=vs.60%29.aspx
http://www.profsr.com/vb/vbless04.htm
http://www.tutorialspoint.com/vb/vb_basic_controls.htm
http://pluto.ksi.edu/~cyh/cis504/ebook/VB02.html

You might also like