Académique Documents
Professionnel Documents
Culture Documents
NDHRA PRADESH
Name of the faculty : G. Radha
Designation : Lecturer
Branch : CCP
Institute : SG Govt. Polytechnic, Adilabad
Year / Semester : V Semester
Subject : Visual Basic – I
Subject Code : CCP - 503
Topic : Understand designing the user
Interface
Duration : 50 Mts.
Sub Topic : Understand the designing aspects
of VB Forms
Teaching Aids : Animations & Images
CCP-503.5 1
Objective:
Design VB forms
Recap
Help System in VB
Saving, Debugging and Distributing of VB
Application
CCP-503.5 3
Following points will be covered
in this Period
CCP-503.5 4
Designing aspects of VB Form
Any Visual Basic application is developed by using the
following steps
Creating the user interface in VB
Setting properties of the elements of user
interface
Writing code by using Methods and Events of the
elements
Running the application
CCP-503.5 5
Creating the Interface
The interface is that part of the application which
is visible to user
VB makes it easy to create a user interface by
simply dragging controls onto a form
User is not aware of the code that is executing
behind the interface.
CCP-503.5 6
Form control
Form is one of the most basic object in which
application is developed
A Form is a window that contains the
application code
Other objects are placed on the form to
create the user interface
Drawing a Control on a Form
We can draw a control on a form in two
ways.
Method1:
Double click on the control in the tool box.
Automatically the control will be placed at
the centre of the form.
Resize and place it at the required place on
the form.
Drawing a Control on a Form
Method2:
CCP-503.5 9
Setting Properties
CCP-503.5 10
Properties Window
CCP-503.5 11
Writing Code
CCP-503.5 12
Methods
Methods are the actions that can be carried out
by objects.
Some methods are simple verbs that tell the
object the action to carry out.
Eg. Clear, move, Additem, Removeitem etc.,
Events
Event determine the control’s reactions to external
conditions
Controls recognise events, but our application handles
them.
For example a command button recognise that it was
clicked, but it won’t react to the event unless we
provide some code.
Eg. Click, DblClick, GotFocus, SetFocus etc.
Events are various things that can happen in a
program. For ex. Textbox control events such as
Change, Click etc..
Code Window Dialogue Box
VB programs are written in code window
To open the code window Double Click in any part
of Form or Control
CCP-503.5 15
Code Window Dialogue Box
CCP-503.5 16
Running the Application
CCP-503.5 17
Code Writing Example
CCP-503.5 18
Code Writing Example (Contd..)
CCP-503.5 19
Code Writing Example (Contd..)
Private Sub cmdDisplay_Click()
Text1.text = “Hello, Welcome to VB Environment”
End Sub
Type the following code in cmdExit_Click() event
between the Sub and End Sub statements
Private Sub cmdExit_Click()
End
End Sub
To run the application click Run Menu ->Start or
F5 Function Key or Arrow Mark on the
Standard Tool Bar
CCP-503.5 20
Sample Form Lay Out
CCP-503.5 21
Sample Code for cmd Display
Command Button
CCP-503.5 22
Sample Code for cmd Exit
Command Button
CCP-503.5 23
Screen After Running the Program
CCP-503.5 24
Summary
CCP-503.5 25
Quiz
CCP-503.5 26
1. To run VB application which of the
following Function key is pressed ?
A. F1
B. F4
C. F5
D. F3
CCP-503.5 27
2. To change the name of Form what is to be changed ?
A. Form Property
B. Form Event
C. Form Procedure
D. Caption property
CCP-503.5 28
Frequently Asked Questions
CCP-503.5 29