Programming (OLD) - Visual Basic Revision Tour

 CBSE Class 12 Informatics Practices

Revision Notes
Chapter - 4
Visual Basic Revision Tour

Intrinsic Controls in Visual basic
The visual basic 6.0 provides some standard controls on its control box which are known as intrinsic control. These are built-in controls and are contained in Visual basic .EXE file. These are different from the extrinsic controls (ActiveX objects and Insertable objects) in the sense that they always reside in the control toolbox, while the others are required to be inserted through the components.

TOOL BOX

The following table is describing the basic controls, their functionality, naming conventions and some important properties and commonly used methods. The letters in ITALICS show the methods generally used with these properties.

Describing the intrinsic control

S. No.

Control

Naming Convention

Important properties

Functionality

1.

Picture Box

Pic

Borderstyle, picture, autosize LoadPicture()

Displays a graphic from a bitmap, icon or metafile.

2.

Label

Lbl

Alignment, wordwrap, autosize, borderstyle

Displays text that a user can't change directly.

3.

Textbox

Txt

Text, max length, multiline, scrollbar, password character, seltext, selstart

Displays information entered at design time by the user, or in code at run time.

4.

Frame

Fra

Visible, borderstyle, appearance

Provides an identifiable grouping for controls.

5.

Command button

Cmd

Enabled, font, style, top visible.

Looks like a push button and is used to begin, interrupt, or end a process.

6.

Checkbox

Chk

Alignment, enabled, value

Displays an X when selected; the X disappears when the Checkbox is cleared.

7.

OptionButton

Opt

Alignment, enabled, value, style

Displays an option that can be turned on or off.

8.

ComboBox

Cbo

Appearance, borderstyle, visible.

Combines the features of a TextBox control and a ListBox control.

9.

List Box

Lst

Multiselect , sorted, style AddItem(), RemoveItem(), Clear(), list()

Displays a list of items from which the user can select one or more.

10.

HScrollbar

hsb

Min, max, Value, LargeChange, smallChange

Provides a horizontal scroll bar for easy navigation through long lists of items.

11.

VScrollbar

vsb

Min, max, Value, LargeChange, smallChange

Provides a vertical scroll bar.

12.

Timer

tmr

Enabled, interval, index Timer()

A control which can execute code at regular intervals by causing a Timer event.

13.

DriveListBox

drv

drive

Enables a user to select a valid disk drive at run time.

14.

DirListBox

dir

path

Displays directories and paths at run time.

15.

FileListBox

fil

Path, pattern

Locates and lists files in the directory specified by the Path property at run time.

16.

shape

shp

Only for decorative purpose on Form Shape, bordercolor, fillcolor

A graphical control displayed as a rectangle, square, oval, circle or rounded rectangle or square.

17.

Line

lin

Only for decorative purpose on Form Shape, bordercolor, fillcolor, borderstyle, borderwidth

A graphical control displayed as a horizontal, vertical or diagonal line.

18.

Image

img

Appearance, borderstyle, picture, stretch LoadPicture()

Displays a graphic.

19.

Data

dat

DatabaseName, recordsource, Readonly, exclusive

Provides access to databases using a Recordset object.

20.

OLE

ole

Class. Sourcedoc, Sourceitem, OLETypeAllowed

Enables you to add insertable objects to the forms of your applications.

Name, Caption (or text in case of textbox), font, are common properties of all controls which are related to the controls basic properties.

How to use the properties within a particular control:
Syantax: Controlname. property=value
Ex:- txtcountry.text=”India” here the txtcountry is a text box assigned a value of “India " to its property text.

How to use the properties within a particular control:
Syantax: Controlname.method(parameters)
Ex:- lstname.additem(“my name”) the method additem is here adding a new item in the listbox.
The codes using these properties and/or methods are generally written either within a function, procedure or an event-procedure while writing a VB 6.0 programs.

Control Categories :

There are three broad categories of controls in Visual Basic:

  • Intrinsic controls, such as the command button and frame controls. These controls are contained inside the Visual Basic .exe file. Intrinsic controls are always included in the toolbox, unlike ActiveX controls and insertable objects, which can be removed from or added to the toolbox.
  • ActiveX controls, which exist as separate files with a .ocx file name extension. These include controls that are available in all editions of Visual Basic (DataCombo, DataList controls, and so on) and those that are available only in the Professional and Enterprise editions (such as Listview, Toolbar, Animation, and Tabbed Dialog). Many third-party ActiveX controls are also available.
  • Insertable Objects, such as a Microsoft Excel Worksheet object containing a list of all your company's employees, or a Microsoft Project Calendar object containing the scheduling information for a project. Since these can be added to the toolbox, they can be considered controls.