Common Controls in VB 6.0
Controls are UI elements placed on Windows Forms. Every application has some user input elements in order get some input and provide output. For this purpose visual basic design interface - IDE (Integrated Development Environment) provides some default controls. The controls collection are not limited to the default system controls. The controls can be extened by using activex controls from project -> Components... menu.
The most commonly used controls in vb 6.0 are label, textbox and command button controls. Combobox, listbox, checkbox are other important controls. In this tutorial we will discuss these basic vb control elements. In subsequent lessons i will provide the properties, methods and events for each control with example and sample source code.
PictureBox:
The vb control to display a graphical picture on windows form. You will use picture box's picture proerty to set an image to display. JPEG, BMP, GIF and some other formats are supported.
Label:
The label control is used to display informative text on the windows form. This is commonly descriptive text before each input element. For example, for textbox control for the input of customer name, a label is used before the textbox control with caption 'customer name'. The common property is Caption property used to change the display text. vb .net use 'text' property instead of 'caption'.
Textbox:
Textbox is the most common control used in vb projects. The first controls used on any vb .net project is lable and textbox. Text box supports a number of properties to change the appearance and functionality of the textbox. The most common property is 'text', which represents the displayed text inside the textbox control. BackColor and Forecolor are used change the display color of the control. You can use PasswordChar to hide the character typed with star(*). You can use MultiLine property to type multiple lines inside the textbox. Richtextbox is and activex control that support full text formatting as microsoft word.
Frame:
In vb 6.0, Frame controls are placeholders that group similar controls. Option buttons are commonly put inside frames for similar purpose. Caption is the common property. In vb .net the frame control is called Groupbox. Dot net has some improved functionality.
Checkbox
In vb 6.0 checkboxes are used to give yes or no type inputs. You can tick or untick the checkbox. 'Value' property is the common property. The two values for this property is 1-checked and 0-unchecked.
OptionButton:
Optionbutton is otherwise called radiobutton. In old radio transistors band selection was used with buttons. If you select one button all other buttons are deselected. Radiobutton serve the similar purpose. The common property is 'Value', which is either True or False.
Combobox:
The combobox another good vb 6.0 control used to display a list of values or strings. You can add items in the combobox using the addditem function during run time code or List property during design time. Style is another common property which has 0-Dropdown combo, 1-Simple combo, 2-Dropdown list.
Listbox:
Listbox serves similar purpose as combobox. Combobox occupies a small size on the screen while listbox occupies a lot of space. Both controls supports database connectivity. You can connect to sql, ms-access databases and tables to display field values.
HScrollBar: Horizontal scroll bar
VScrollBar: Vertical Scroll bar
Timer:
Timer control is the non-visibile control added on the windows form. Timer control's timer event will fire at specifed 'interval' in milliseconds.
Drivelistbox:
The drivelistbox control is used to display and select Disk drives mounted on the computer. You need not set any property for this control to work. You just add the control on the form.
DirListbox:
Displays list of directories in the Drive, set in path property.
FileListBox:
Displays list of files in the selected drive and directory.
Image:
Displays graphics images on windows forms.
Data:
Only built-in vb 6 control to fetch data from databases like oledb, odbc, sql, oracle etc. ADODB control is commonly used. sophisticated programs use reference to Microsoft Activex Data object library