Controls are used to get user input and to display output. Controls encapsulate (hides) all sort of functionality and data. There are three categories of controls in Visual Basic:
- Intrinsic. The standard controls in the toolbox.
- ActiveX. Controls that can be added to the toolbox. These files will have an .ocx file name extension for VB6 and .vbx for older versions of VB.
- Insertable Objects. These are items that can be added to the toolbox but are actually objects outside of Visual Basic, eg a Microsoft Excel Worksheet object. Some of these objects support OLE Automation.
For capabilities beyond the core language and controls of Visual Basic, calls need to be made to procedures in DLLs (Dynamic Link Libraries).
- Controls providing users choices
- CheckBox** The user can select one or more from a set of these. Value = Value. Prefix = chk.
- OptionButton** A set of these are grouped into option groups by the form or by a frame within a form. The user can select only one from the set. Value = Value. Prefix = opt.
- TextBox** Provides the user a choice to enter text. Value = Text. Prefix = txt or tbx..
- ListBox** Provides the user a choice of one or more from a list of any length. Value = Text. Prefix = lst or lbx.
- ComboBox** Provides a choice of one or more from a list, or to enter text. Value = Text. Prefix = cbo.
- CommandButton Carries out code when a user chooses it. Value = Value. Prefix = cmd.
- If Command.Cancel = True, then the button is clicked whenever ESC is pressed.
- If Commnad.Default = True, then the button is clicked whenever RETURN is pressed.
- Graphic Controls
- Label** Displays text that the user cannot modify or interact with. Value = Caption. Prefix = lbl.
- Shape Draws simple shapes (rectangles and ellipsoids) on the form, frame, or picture box. Prefix = shp.
- Line Draws straight line segments on the form. Value = Visible. Prefix = lin.
- Image** Displays a picture (BMP, ICO, WMF, JPG, or GIF). Can also act like a command button. Value = Picture. Prefix = img.
- PictureBox** Like an image control but it can also be a visual container for other controls. It has multiple methods including ways to animate. Value = Picture. Prefix = pic.
- Frame Provides a visual and functional container for other controls. Value = Caption. Prefix = fra.
- HScrollBar and VScrollBar Allows the user to use scroll bars to view data. Value = Value. Prefix = hsb & vsb.
- File System Controls
- DriveListBox A list box showing drives available to the user. Value = Drive. Prefix = drv.
- DirListBox A list box showing directories in the selected drive. Value = Path. Prefix = dir.
- FileListBox A list box showing files in the selected directory. Value = FileName. Prefix = fil.
- Timer Executes code at recurring intervals. Value = Enabled. Prefix = tmr.
- Data Enables a connection to a database (usually DOA) and allows the user basic navigation through the database. Value = Caption. See also the ActiveX control called adodc. Value = Caption. Prefix = dat or dc.
- OLE** Provides access to OLE enabled applications. Usually embeds data into the application. Prefix = ole.
**Bindable control, i.e. can show field values for the current record of the dataset.
For prefix conventions, see Identifiers.
|
Component Name |
File Name |
Control (Class Name if Different) |
Prefix |
|
Microsoft ADO Data Control 6.0 |
MSADODC.OCX |
ADO Data Control (Adodc) |
ado |
|
Microsoft Chart Control 5.5 |
MSCHART.OCX |
Microsoft Chart (MSChart)** |
cht |
|
Microsoft Comm Control 6.0 |
MSCOMM32.OCX |
MSComm |
cmm |
|
Microsoft Common Dialog Control 6.0 |
COMDLG32. OCX |
CommonDialog |
dlg or cdg or cdl |
|
Microsoft Data Bound Grid Control 5.0 |
DBGRID32.OCX |
DBGrid** |
grd |
|
Microsoft Data Bound List Controls 6.0 |
DBLIST32.OCX |
DBList**, DBCombo** |
lst, cbo |
|
Microsoft Data Repeater Control 6.0 |
MSDATREP.OCX |
DataRepeater** |
drr |
|
Microsoft Data Grid Control 6.0 |
MSDATGRD.OCX |
DataGrid** |
grd |
|
Microsoft Data List Controls 6.0 |
MSDATLST.OCX |
DataList**, DataCombo** |
lst, cbo |
|
Microsoft FlexGrid Control 6.0 |
MSFLXGRD.OCX |
MSFlexGrid** |
grd |
|
Microsoft Grid Control
|
GRID32.OCX |
Grid** |
grd |
|
Microsoft Hierarchical Flex Grid Control 6.0 |
MSHFLXGD.OCX |
Hierarchial FlexGrid (MSHFlexGrid)** |
grd |
|
Microsoft Internet Transfer Control 6.0 |
MSINET.OCX |
Internet Transfer control (Inet) |
itx |
|
Microsoft MAPI Controls6.0 |
MSMAPI32.OCX |
MAPIMessages, MAPISession (MAPI) |
map |
|
Microsoft MaskedEdit Control 6.0 |
MSMASK32.OCX |
MaskedEdit (MaskEdBox)** |
mbx |
|
Microsoft Multimedia Control 6.0 |
MCI32.OCX |
Multimedia MCI (MMControl) |
mci |
|
Microsoft PictureClip Control 6.0 |
PICCLP32.OCX |
PictureClip |
pic or pbx |
|
Microsoft RemoteData Control 6.0 |
MSRDC20.OCX |
RemoteData |
rdc |
|
Microsoft RichTextBox Control 6.0 |
RICHTX32.OCX |
RichTextBox** |
rbx |
|
Microsoft SysInfo Control 6.0 |
SYSINFO.OCX |
SysInfo |
sys |
|
Microsoft TabbedDialog Control 6.0 |
TABCTL32.OCX |
Tabbed Dialog (SSTab) |
tdg |
|
Microsoft Windows Common Controls 6.0 |
MSCOMCTL.OCX |
TabStrip, Toolbar, StatusBar, ProgressBar, TreeView, ListView, ImageList, Slider, ImageCombo** |
tab, tbr, sbr, pbr, tvw, lvw, ilt, sld, icb |
|
Microsoft Windows Common Controls-2 6.0 |
MSCOMCT2.OCX |
Animation, UpDown, MonthView**, DateTimePicker (DTPicker)**, FlatScrollbar |
anm, udn, mvw, dtp, fsb |
|
Microsoft Windows Common Controls-3 6.0 |
COMCT332.OCX |
CoolBar |
cbr |
|
Microsoft Winsock Control 6.0 |
MSWINSCK.OCX |
Winsock |
wsk |
**Bindable control, i.e. can show field values for the current record of the dataset.
For prefix conventions, see Identifiers.
- The About Property contains information about the ActiveX control's vendor.
- An ActiveX control must be registered in the system registry if it is to be used.
- The value of a control is the property that can be used to store or retrieve values just by referring to the control's name. The name of the property varies for different kinds of controls.
- A Control Array is a group of controls that share the same name and type. Control Arrays are referenced with an index number up to 32767, eg
optName(1). Control Arrays use fewer resources than creating multiple controls of the same type but with different names. There are also some programmatic advantages to using Control Arrays. EG: One event procedure can be created for the entire control array, since the event will also pass the index number of a particular control in the array.
- The tab order is the order of focus when the TAB key is pressed. TabIndex = 0 for the first and default focus. A control can be removed from the tab order (and still maintain its TabIndex) by setting its TabStop property to False.
- Some of the controls are variations or updates on older controls, specifically from DAO oriented to ADO oriented:
- Data control --> Adodc
- DBList --> DataList
- DBCombo --> DataCombo
- Grid --> DBGrid --> DataGrid
- MSFlexGrid --> MSHFlexGrid
- Pull Down Menus can have a separator the menu item's caption to a hyphen (-). The following code allows a context menu (pop-up menu) show up for an object:
Private Sub Object_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu mnuHidden
End If
End Sub
- InputBox Displays a box requesting a text response from the user. This box is modal, meaning nothing else in the application can be taken cared of until a response is given. Here is typical code to make an Input Box:
Response = InputBox("Comment requesting response:", "Box Title")
- MsgBox Displays a box requesting a click response from the user. This box is modal, meaning nothing else in the application can be taken cared of until a response is given. Here is typical code to make a MsgBox:
MsgBox "Comment in box", vbExclamation, "Box Title"
2007-09-20 19:36:08Z