Bit 3102 Practical Notes
Bit 3102 Practical Notes
BASIC6.0
Visual Basic 6.0
VB is an Event- Driven programming
VB has different objects called Forms and Controls.
Each object has its own properties (Colour, height, name etc)
•
• Controls: The boxes and on the form (text boxes, command button etc
) are referred to as controls.
Properties
window
Tool
bar
Form
window
Propertie
FIG 1.2 COMPONENTS OF WINDOW s layout
Tool box
window
MENU BAR AND TOOL BAR
Menu
bar
MENU BAR-
The menu bar(fig 1.4) consists of
Many drop-down menus.Clicking on any of
The option ofthe menu bar makes it
Active.
TOOL BAR-
The tool bar(fig 1.4) has buttons that
Provide some of the menu options.
FORM WINDOW
The form window is the primary
work area that forms the
background of the application
.The user can draw objects on
the form.
TOOLBOX
The toolbox contains icons that
represent commonly used controls
such as label, textbox, command
button ,etc.
PROJECT WINDOW
IT DISPLAYS A LIST OF ALL FORMS THAT MAKES UP
THE APPLICATION.IT HAS THREE BUTTONS ON THE
TOP LEFT.(FIG 1.7)
1.CLICK ON VIEW OBJECT TO OPEN A FORM.
2.CLICK ON VIEW CODE TO OPEN CODE WINDOW.
View Select
Code form
View
object
e.g Amt=2564.5643
FormatNumber(Amt,2) will display 2,564.56
FormatNumber(Amt,0) will display 2,565
Simple project in VB
Object property Value
Form Name frmTybcom
Caption My First Form
Label Name lblName
Caption Good Morning Students
Command Button Name cmdWelcome
Caption &Welcome
Command Button Name cmdExit
Caption &Exit
• Steps to Create Project:
Click at File New
Go to property window change Name as
frmTybcom and Caption as My First Form
Click at Label from the Toolbox, Go to Form and
draw a rectangle for message
Goto property window change Name as lblName
and caption as Good Morning Students
Click at Command button from the Toolbox, goto
form and draw rectangle for Welcome
Goto property window change Name as
cmdWelcome and Caption as Welcome
Click at Command button from the Toolbox, goto
form and draw rectangle for Exit
Goto property window change Name as cmdExit and
Caption as &Exit
Double click on Welcome command button to go to
the code window and type
MsgBox “Welcome to learn Visual Basic” in between
Private Sub cmdWelcome_Click and End Sub
Double click on Exit command button to go to the
code window and type End in between Private Sub
cmdExit_Click and End Sub
Click at File Save project
Press F5 to Run or Run Start
Practical No:1
1.Write a project in VB to design a suitable form to
add two numbers and display their sum
Enter Number1
Enter Number2
SUM IS
No. of years
Rate of Interest
Interest Amount
OK 0 vbOKOnly No Icon
Critical Message 16 vbCritical
Icon
Warning Query 32 vbQuestion
Icon
Warning Message 48 vbExclamation
Information 64 vbInformation
Message
Decisions and conditions
If….Then….Else Statement
For E1 = E2 To E3 Step E4
----------------
Statements to be repeated
----------------
Next E1
Where E1 = Control or Index Variable
E2 = Initial value
E3 = Final value
E4 = Increment in E1 after every repetition
Example
For I=1 to 5
Sum=Sum+I
Next I
PRACT_NO-12
1. Write a project in VB to design a suitable form which
allow the user to enter any integer and then display the
sum of all integer upto that integer
( i.e 1 + 2 + 3 + 4 + ……… + n)