Professional Documents
Culture Documents
Controls
Version 1
1
Trg. Div., NIC HQRs
Controls
Version 1
2
Trg. Div., NIC HQRs
ToolBox
? Tool Box contains the standard controls.
? You can add more controls by from
components
? You can create your own controls ActiveX
controls customised to specific purposes
Version 1
3
Trg. Div., NIC HQRs
Pointer Picture Box
Version 1
5
Trg. Div., NIC HQRs
Property
? With each object , various properties are
associated which describe its characteristics. The
properties can be set at design time by using
property window or at run time through program
statements
Eg: Command1.Caption = “ Hello”
? .
Program Statement
It is a keyword in the code that does the work of a
program
Version 1
7
Trg. Div., NIC HQRs
Variable
? Itis a special container that holds data
temporarily in a program
? Numbers, Charatcter strings, property
values etc can be stored in variables
Eg : Dim db As Database
Dim strdiv As String
Dim rs As Recordset
Country = “India” etc.
Version 1
8
Trg. Div., NIC HQRs
Method
? Itis a special statement that performs an
action or a service for a particular object in
a program
Syntax : Object.Method Value
Eg : List1.AddItem “Printer”
ShowOpen
SowPrint etc.
Version 1
9
Trg. Div., NIC HQRs
Form Events
? Whenever an event is triggered ( click, drag,
resize, double click, key press etc.) a message is
generated that describes your action.This message
is sent to appropriate control, which in turn
generates appropriate action based on pre-defined
method.
? The event message can be customised the way
action needs to be taken by writing your own code
Version 1
10
Trg. Div., NIC HQRs
Event Procedure
? Itis a block of code that is executed when
an object is manipulated in a program.
Eg: When an event takes place, block of
program code associated with it gets
executed.
Few common events are :
Click, Dbclick, MouseDown, MouseUp,
MouseMove etc.
Version 1
11
Trg. Div., NIC HQRs
Form Methods
? It is a command that allows you to tell an
object what to do
eg: Show
hide, Unload, Print
An example of programming construct:
If Lable1.Caption = “xxx” Then hide form1
Object Property Assigned VB method Object
name name Operator Function
Version 1
12
Trg. Div., NIC HQRs
Nomenclature convention of
the objects
For forms ( three nomenclatures are associated with it)
1. Name of the object form
2. Name of the caption of the form
3 Form file name for saving it as a part of project
To avoid any confusion later, one should follow a convention of
nomenclature, and should strictly follow throughout the project
.
Version 1
13
Trg. Div., NIC HQRs
Nomenclature convention of
the objects
For other objects
Version 1
14
Trg. Div., NIC HQRs
Pointer
The pointer is used for
selecting objects which is
to placed on the form.
Version 1
15
Trg. Div., NIC HQRs
Picture box
.BMP Bitmap
.WMF Windows MetaFile
.ICO Icons
.GIF Graphic Interchange Format
.JPG Joint Photographic Expert Group
. DIB Device Independent Bitmap
.EMF Enhanced MetaFile
Version 1
16
Trg. Div., NIC HQRs
Image Control
Version 1
17
Trg. Div., NIC HQRs
Labels and Text Boxes
Version 1
18
Trg. Div., NIC HQRs
USE OF TEXTBOX & COMMAND BUTTON
Version 1
19
Trg. Div., NIC HQRs
Frame Control
Version 1
21
Trg. Div., NIC HQRs
Option buttons
Version 1
24
Trg. Div., NIC HQRs
Combo box
Version 1
25
Trg. Div., NIC HQRs
Use of Combo box
1. Drag the List Box on the Form
2. Double Click the List Box and type the
following
Private Sub Form_Load()
Combo1.AddItem "one"
Combo1.AddItem "two"
Combo1.AddItem "three"
Combo1.AddItem "four"
Combo1.AddItem "five"
Combo1.AddItem "six”
End Sub
3. Run
Version 1
26
Trg. Div., NIC HQRs
Horizontal and Vertical scroll bars
Version 1
27
Trg. Div., NIC HQRs
Timer
EXAMPLE
Version 1
28
Trg. Div., NIC HQRs
Private Sub Command1_Click()
If Text1.Text = "secret" Then
Timer1.Enabled = False
MsgBox ("Welcome To the System")
Else
MsgBox ("Sorry, Friend, I don't know you.")
End If
End Sub
The Drive List box,Directory List box and File List box
can be used together to give the standard Windows
file management facilities. When the program runs
they will initially display the current drive and
directory. These can be changed by clicking and
highlighting in the usual way. Three boxes together
can produce a highly efficient file selection routine.
Version 1
30
Trg. Div., NIC HQRs
USE OF DRIVELISTBOX, DIRECTORY LISTBOX ,
FILE LISTBOX & IMAGE CONTROLS
1. Click theDriveListBox in the toolbox.
2. Move the mouse pointer to the upper-left corner of the form and
then draw a drivelistbox.
3. Similarly draw the Directorylistbox and filelistbox.
4. Add the image box control to the right side of your form.
5. Double click the drivelistbox and type the following
Dire1.Path = Drive1.Drive
Close the Code window
6. Double click the directorylistbox and type the following
File1.Path = Dir1.Path
Close the Code window
7. Double click the Filelistbox and add the following code to the
File1_Click event procdure.
SelectFile = File1.Path & “\” & File1.filename
Image1.Picture = LoadPicture(SelectedFile)
Version 1
8. Now Run the program. Trg. Div., NIC HQRs 31
The Shapes (either a circle, oval, square or
rectangle)
and Line are purely for decorative purpose
Version 1
32
Trg. Div., NIC HQRs
Data Control
Version 1
33
Trg. Div., NIC HQRs
OLE
OLE stands for Object Linking
and Embedding. This control
allows you to make a two way
link with an object in another
Windows application.
Version 1
34
Trg. Div., NIC HQRs