Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home4/sambenne/public_html/samsvb/includes/dbc.php on line 3
Visual Basic 6 Tutorials

Lesson 5 Main Controls

p class="main"> Controls that are built in to VB are called intrinsic controls , and are available to all VB programs. All of the intrinsic controls appear in the Toolbox. ActiveX Controls are controls that exist as separate files with the extension .OCX . Before you can use an ActiveX control, it must be registered in the Windows Registry. If you have a control which has not been registered by other software, you can register it using a program called REGSVR32, which comes with all version of Windows. To use it, simply type in: REGSVR32 control.ocx , where control.ocx is the filename of the control to be registered. Most VB projects will use a number of intrinsic controls, together with a (usually smaller) number of ActiveX controls that provide specific functionality not provided by the intrinsic controls.

Intrinsic Controls

Visual Basic comes with 20 built-in controls (excluding the pointer), which are summarised below. Some controls are used on virtually every application. Others are only used when a specific need arises. Several of these controls can display or edit data from a database. The intrinsic controls provided with all version of Visual Basic are shown below.

Visual Basic Intrinsic Controls
Pointer Pointer Picture PictureBox Label Label
TextBox TextBox Frame Frame CommandButton CommandButton
CheckBox CheckBox OptionButton OptionButton ComboBox ComboBox
ListBox ListBox HScrollBar HScrollBar VScrollBar VScrollBar
Timer Timer DriveListBox DriveListBox DirListBox DirListBox
FileListBox FileListBox Shape Shape Line Line
Image Image Data Data OLE OLE
  • PictureBox - a fairly simple control that lets you display, draw and save images. It can also contain other controls
  • Label - used to label other controls by displaying text information
  • TextBox - a box that can accept text input (up to 2048 characters by default) from a user, or display text.
  • Frame - a container that can hold other controls - often used to manipulate controls as a group
  • CommandButton - executes a block of code in response to a user action such as a click or a mouse over
  • CheckBox - typically used for turning on or off some feature of an application
  • OptionButton - allows the user to select one ofption from a group of options
  • ComboBox - a combination of a TextBox and a ListBox that allows the user to select from a drop-down list or enter new text
  • ListBox - allows the user to select an item from a drop-down list
  • HScrollBar - allows you to add a horizontal scrollbar to an application
  • VScrollBar - allows you to add a vertical scrollbar to an application
  • Timer - used to perform an action at a specific time
  • DriveListBox - normally used in conjunction with DirListBox and FileListBox
  • DirListBox - normally used in conjunction with DriveListBox and FileListBox
  • FileListBox - normally used in conjunction with DriveListBox and DirListBox
  • Shape - used to draw shapes such as rectangles, ellipses and circles, often as part of an animation
  • Line - used to draw lines, often as part of an animation
  • Image - used to display an image
  • Data - used when accessing a database to provide an interface for other controls
  • OLE - used to link objects from other applicationson to a VB application

ActiveX Controls

The Professional Edition of Visual Basic provides a number of ActiveX controls, none of which are normally shown in the Toolbox. You can insert ActiveX controls into the Toolbox as you require them (right-click on the toolbox, select Components , check the controls to include, and press OK ). The ActiveX controls are illustrated below.

Visual Basic ActiveX Controls
SSTab SSTab MSFlexGrid MSFlexGrid CommonDialog CommonDialog
TabStrip TabStrip ToolBar ToolBar StatusBar StatusBar
ProgressBar ProgressBar TreeView TreeView ListView ListView
ImageList ImageList Slider Slider ImageCombo ImageCombo
Animation Animation UpDown UpDown MonthView MonthView
DTPicker DTPicker FlatScrollBar FlatScrollBar Inet Inet
RichTextBox RichTextBox MSChart MSChart WinSock WinSock
MAPISession MAPISession MAPIMessages MAPIMessages MMControl MMControl
PictureClip PictureClip SysInfo SysInfo MSComm MSComm
MaskEdBox MaskEdBox DataGrid DataGrid DataList DataList
DataCombo DataCombo CoolBar CoolBar Adodc Adodc
MSHFlexGrid MSHFlexGrid        
  • SSTab - provides a method of displaying multiple dialog boxes using tabs
  • MSFlexGrid - displays and operates on tabular data, providing flexible sorting, merging, and formatting of table data
  • CommonDialog - allows a user to navigate through drives and folders and select a file
  • TabStrip - allows multiple pages to be defined for the same area of a window or dialog box
  • ToolBar - used to create a toolbar for an application
  • StatusBar - used to display messages about the status of an application
  • ProgressBar - monitors the progress of an operation carried out within the application
  • TreeView - displays hierarchical data and allows a user to navigate the hierarchy by expanding and collapsing nodes
  • ListView - an advanced version of ListBox that supports icons, multiple columns, and other features
  • ImageList - contains a collection of images that can be used by other controls (e.g. ListView, TreeView, TabStrip, and Toolbar)
  • Slider - similar to a scroll bar, this control is used to adjust or select from a continuous range of values
  • ImageCombo - similar to a ComboBox, except that pictures can be included with each item in the selection
  • Animation - displays silent AVI clips (an AVI clip is a series of bitmap frames like a movie)
  • UpDown - a pair of arrow buttons that the user can click to increment or decrement a value in another control
  • MonthView - enables users to view and set date information via a calendar-style interface
  • DTPicker - provides a formatted date field that allows easy date selection from a dropdown calendar interface
  • FlatScrollBar - a mouse-sensitive two-dimensional scroll bar
  • Inet (Internet Transfer Control) - used to send and retrieve documents across the Internet using FTP or HTTP
  • RichTextBox - allows the application to create text in RTF format that can then be read by other applications
  • MSChart - this control is used in association with a DataGrid object that holds the data being charted
  • WinSock - used to create applications that access low-level TCP/IP functions
  • MAPISession - used to open and close a MAPI session (used with MAPIMessages to create mail-enabled VB applications)
  • MAPIMessages - enables user to perform various messaging system functions (see MAPISession)
  • MMControl - used to manipulate multimedia files
  • PictureClip - stores multiple images in a single bitmap for use by other controls - often used to create animations
  • SysInfo - provides the application with a means of gathering system information
  • MSComm - provides serial communications by allowing the application to transmit and receive data via a serial port
  • MaskEdBox - restricts data input to a specific format and supplies visual cues about the type of data being entered or displayed
  • DataGrid - displays and operates on tabular data, providing flexible sorting, merging, and formatting of table data
  • DataList - used to display a list of items that are bound to the control in a table
  • DataCombo - a data-bound combo box that is automatically populated from a field in an attached data source
  • CoolBar - a container control for creating user-configurable toolbars similar to those seen in Internet Explorer
  • Adodc - database controls use ADODC to access a database
  • MSHFlexGrid - displays and operates on tabular data, providing flexible sorting, merging, and formatting of table data
Courtesy of Chris Wells.