What is a Control in Visual Basic (VB)?
In Visual Basic, a control is a graphical component or object placed on a form that allows users
to interact with the application. Controls are used for displaying information, receiving user
input, and performing specific actions. They are the building blocks of a Visual Basic
application's user interface (UI).
Controls can be added to forms at design time using the toolbox or dynamically at runtime
through code.
Common Uses of Controls:
Display text or images
Get user input (like text, numbers, choices)
Trigger events such as clicking a button or selecting an item
Examples:
TextBox – to enter text
Label – to display text
Button (CommandButton) – to perform an action
CheckBox/OptionButton – for multiple/single selections
ComboBox/ListBox – to select from a list
Types of Controls in Visual Basic
Controls in VB can be broadly classified into the following categories:
1. Intrinsic Controls
These are built-in controls available in the VB toolbox by default. They are commonly used in
most applications.
Examples:
Label – Displays static text
TextBox – Accepts user input
CommandButton – Executes actions on click
CheckBox – Allows multiple selections
OptionButton (RadioButton) – Allows single selection from a group
ListBox/ComboBox – Displays a list of items
2. Container Controls
These controls can contain or group other controls. They help in organizing the form layout.
Examples:
Form – The main window that holds other controls
Frame – Groups related controls
PictureBox – Can display images and also hold other controls
3. Menu and Toolbar Controls
These controls are used for creating menus and toolbars, enhancing the application's navigation.
Examples:
Menu Editor – Creates menu bars with options like File, Edit, etc.
Toolbar – Offers shortcut buttons for frequent actions
4. Data Controls
Used for connecting, accessing, and displaying data from databases. These controls simplify
database operations.
Examples:
DataGrid – Displays data in a table format
ADODC (ActiveX Data Object Data Control) – Used to connect to databases
DataCombo/DataList – Binds data from a source for selection
5. ActiveX Controls (Custom Controls)
These are external controls not provided by default. They must be added separately and provide
extended functionalities.
Examples:
RichTextBox – Allows formatting text (bold, italic, etc.)
Common Dialog Control – Provides standard dialogs like File Open, Save, Print
Calendar Control – Lets users select dates from a calendar