0% found this document useful (0 votes)
62 views55 pages

VB Lab Print

Uploaded by

yuvarajacb11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views55 pages

VB Lab Print

Uploaded by

yuvarajacb11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CONTENTS

PAGE
S.NO DATE PROGRAM NAME SIGNATURE
NO

1 SIMPLE ARITHMETIC CALCULATOR

2.a FIBONACCI SERIES

2.b SUM OF N NUMBERS

TRIANGLE FORMAT
2.c

CREATING MENU AND MDI FORM


3

SIMPLE INPUT SCREEN WITH BASIC


4
CONTROLS

5 FILES IN A DIRECTORY

6 COMMON DIALOG CONTROL

7 STUDENT REGISTRATION FORM

8 DATABASE USING ADO

9 PERSONAL INFORMATION SYSTEM

10 ANIMATION USING TIMERS


EX NO: 1 SIMPLE ARITHMETIC CALCULATOR
DATE :

AIM
To construction of simple Arithmetic Calculator.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click open.

Step 2: Design the form using necessary components such as Labels, Textbox and
Command buttons to get the Fibonacci series.

Step 3: Change the property legends for necessary components.

Step 4: Develop the source code by selecting components with suitable events to
construction of simple Arithmetic Calculator.

Step 5: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Frame1 Frame1 Calculator

Text1 Text1

Command1 Cmd1 1

Command2 Cmd2 2

Command3 Cmd3 3

Command4 Cmd4 4

Command5 Cmd5 5
Command6 Cmd6 6

Command7 Cmd7 7

Command8 Cmd8 8

Command9 Cmd9 9

Command10 Cmd0 0

Command11 dot .

Command12 equal =

Command13 multiply *

Command14 division /

Command15 plus +

Command16 minus -

Command17 on On/Ac

Command18 off Off

CODING

Dim a As Double
Dim opr As String

Private Sub cmd0_Click()


Text1.Text = Text1.Text + cmd0.Caption
End Sub

Private Sub cmd1_Click()


Text1.Text = Text1.Text + cmd1.Caption
End Sub
Private Sub cmd2_Click()
Text1.Text = Text1.Text + cmd2.Caption
End Sub

Private Sub cmd3_Click()


Text1.Text = Text1.Text + cmd3.Caption
End Sub

Private Sub cmd4_Click()


Text1.Text = Text1.Text + cmd4.Caption
End Sub

Private Sub cmd5_Click()


Text1.Text = Text1.Text + cmd5.Caption
End Sub

Private Sub cmd6_Click()


Text1.Text = Text1.Text + cmd6.Caption
End Sub

Private Sub cmd7_Click()


Text1.Text = Text1.Text + cmd7.Caption
End Sub

Private Sub cmd8_Click()


Text1.Text = Text1.Text + cmd8.Caption
End Sub

Private Sub cmd9_Click()


Text1.Text = Text1.Text + cmd9.Caption
End Sub
Private Sub dot_Click()
Text1.Text = Text1.Text + dot.Caption
End Sub

Private Sub equal_Click()


If (opr = "+") Then
Text1.Text = Val(a) + Text1.Text
ElseIf (opr = "-") Then
Text1.Text = Val(a) - Text1.Text
ElseIf (opr = "*") Then
Text1.Text = Val(a) * Text1.Text
ElseIf (opr = "/") Then
Text1.Text = Val(a) / Text1.Text
End If
End Sub

Private Sub multiply_Click()


opr = "*"
a = Text1.Text
opr = multiply.Caption
Text1.Text = Text1.Text
Text1.Text = " "
End Sub

Private Sub division_Click()


opr = "/"
a = Text1.Text
opr = division.Caption
Text1.Text = Text1.Text
Text1.Text = ""
End Sub
Private Sub plus_Click()
opr = "+"
a = Text1.Text
opr = plus.Caption
Text1.Text = Text1.Text
Text1.Text = ""
End Sub

Private Sub minus_Click()


opr = "-"
a = Text1.Text
opr = minus.Caption
Text1.Text = Text1.Text
Text1.Text = ""
End Sub

Private Sub on_Click()


Text1.Text = " "
End Sub
Private Sub off_Click()
End
End Sub
OUTPUT

RESULT

Thus the above program construction of simple Arithmetic Calculator has been executed
successfully.
EX NO: 2(a) FIBONACCI SERIES
DATE :

AIM

To Generate Fibonacci series using for loop loops and decision making statements .

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click open.

Step 2: Design the form using necessary components such as Labels, Textbox and
Command buttons to get the Fibonacci series.

Step 3: Change the property legends for necessary components.

Step 4: Develop the source code by selecting components with suitable events to
compute the Fibonacci series.

Step 5: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Fibonacci Series


Label2 Label2 Enter the Number
Label3 Label3 Fibonacci Series is
Text1 Text1
Text2 Text2
Command1 cmdcompute Compute

Command2 cmdexit Exit


CODING

Private Sub cmdcompute_Click()


Dim n, a, b, c As Integer
n = Val(Text1.Text)
a=0
b=1
Picture1.Print a & Space(2)
Picture1.Print b & Space(2)
For i = 1 To n - 2
c=a+b
a=b
b=c
Picture1.Print c & Space(2)
Next i
End Sub

Private Sub cmdexit_Click()


End
End Sub
OUTPUT

RESULT

Thus the Fibonacci series program has been executed and verified successfully.
EX NO: 2 (b) SUM OF N NUMBERS

DATE :

AIM
To find the sum of N numbers using for loop loops and decision making statements.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click open.

Step 2: Design the form using necessary components such as Labels, Textbox and
Command buttons to get the sum of N numbers.

Step 3: Change the property legends for necessary components.

Step 4: Develop the source code by selecting components with suitable events to
compute the sum of N numbers.

Step 5: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Sum of N numbers


Label2 Label2 Enter the number
Label3 Label3 Output
Text1 Text1
Text2 Text2
Command1 cmdcompute Compute
Command2 cmdexit Exit
CODING

Private Sub cmdcompute_Click()


Dim i, sum As Integer
If Val(Me.Text1.Text) < 0 Then
MsgBox "Invalid Input", vbCritical
Else
For i = 1 To Val(Me.Text1.Text) Step 1
sum = sum + i
Next i
Text2.Text = "Sum of N numbers from 1 to" & Me.Text1.Text & ":" & sum
End If
End Sub

Private Sub cmdexit_Click()


End
End Sub

\
OUTPUT

RESULT

Thus the sum of series program has been executed and verified successfully.
EX NO : 2 (c) TRIANGLE FORMAT

DATE :

AIM
To display the numbers/symbols in triangle format using for loop loops and decision
making statements.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click open.

Step 2: Design the form using necessary components such as Labels, Textbox and
Command buttons to display the numbers/symbols in triangle format.

Step 3: Change the property legends for necessary components.

Step 4: Develop the source code by selecting components with suitable events to display
the numbers/symbols in triangle format.

Step 5: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Triangular Format


Label2 Label2 Enter number of rows
Label3 Label3 Output
Text1 Text1
Text2 Text2
Command1 cmdrun Run
Command2 cmdexit Exit
CODING

Private Sub cmdrun_Click()

Dim i, rows As Integer

rows = Val(Text1.Text)

For i = 1 To rows

Picture1.Print Space(rows - i) + String(i, "*")

Next i

End Sub

Private Sub cmdexit_Click()

End

End Sub
OUTPUT

RESULT

Thus the triangular format program has been executed and verified successfully.
EX NO:3 CREATING MENU AND MDI FORM

DATE:

AIM

To create a menu and MDI Forms.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click open.

Step 2: Right click the project explorer click add and choose MDI form.

Step 3: Select Tool menu and click menu editor.

Step 4: Give the names for menus and write the code.

Step 5: Save and execute the project.


FORM DESIGN

FORM CODING

Private Sub Form1_Click()


MDIForm1.Show
End Sub

MDI FORM CODING

Private Sub open_Click()


Form1.Show
End Sub

Private Sub Exit_Click()


End
End Sub
OUTPUT

RESULT

Thus the above program menu and MDI Forms has been created and executed
successfully.
EX NO:4 SIMPLE INPUT SCREEN WITH BASIC CONTROLS

DATE:

AIM
To create a simple input screen with four basic controls to read input and write it to a file.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click open.

Step 2: Create Option boxes to display the gender

Step 3: Create command button display the gender in textbox.

Step 4: Develop the source code by selecting components with suitable events to display
the gender.

Step 5: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Enter the name

Text1 Text1

Option1 Option1 Male

Option2 Option2 Female

Command1 cmddisplay Display

Command2 cmdexit Exit


CODING

Private Sub cmddisplay_Click()


If cmdmale.Value = True Then
MsgBox "Mr." & Text1.Text
Else
MsgBox "Mrs." & Text1.Text
End If
End Sub

Private Sub cmdexit_Click()


End
End Sub
OUTPUT

RESULT

Thus the above program, simple input screen with four basic controls to read
input and write it to a file has been created and executed successfully.
EX NO:5 FILES IN A DIRECTORY
DATE:

AIM

To display files in a directory using DriveListBox, DirListBox and FileListBox control


and open, edit and save text file using Rich text box control.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click open.

Step 2: Design the form using necessary components such as Labels, Command buttons,
Drivelistbox, Dirlistbox, FileListBox, Richtextbox and CommonDialog control.

Step 3: Change the property legends for necessary components.

Step 4: Develop the source code by selecting components with suitable events to display
the files.

Step 5: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Files and directory


DriveListBox Drive1
DirListBox Dri1
FileListBox File1
Command1 open Open
Command2 edit Edit
Command3 save Save
Command4 exit Exit
RichTextBox RichTextBox1
Commondialog CommonDialog1
CODING
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub open_Click()


RichTextBox1.LoadFile File1.FileName
End Sub
Private Sub edit_Click()
CommonDialog1.ShowFont
RichTextBox1.SelBold = CommonDialog1.FontBold
RichTextBox1.SelItalic = CommonDialog1.FontItalic
RichTextBox1.SelStrikeThru = CommonDialog1.FontStrikethru
RichTextBox1.SelUnderline = CommonDialog11.FontUnderline
RichTextBox1.SelFontName = CommonDialog1.FontName
RichTextBox1.SelFontSize = CommonDialog1.FontSize
RichTextBox1.SelColor = CommonDialog1.Color
End Sub

Private Sub save_Click()


CommonDialog1.ShowSave
RichTextBox1.SaveFile CommonDialog1.FileName
End Sub

Private Sub exit_Click()


End
End Sub
OUTPUT

RESULT

Thus the above program to display files in a directory using DriveListBox, DirListBox
and FileListBox control and open, edit and save text file using Rich text box control has
been executed successfully.
EX NO:6 COMMON DIALOG CONTROL
DATE:

AIM

To illustrate Common Dialog Control and to open, edit and save text file.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click open.

Step 2: Design the form using necessary components such as Labels, Command buttons,
Richtextbox and CommonDialog control.

Step 3: Change the property legends for necessary components.

Step 4:Develop the source code by selecting components with suitable events to illustrate
Common Dialog control.

Step 5: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Common Dialoug control


Command1 cmdopen Open
Command2 cmdedit Edit
Command3 cmdsave Save
Command4 cmdexit Exit
RichTextBox RichTextBox1
Commondialog CommonDialog1
OUTPUT

RESULT

Thus the above program to illustrate Common Dialog Control and to open, edit and save
text file has been executed successfully.
EX NO: 7 STUDENT REGISTRATION FORM

DATE:

AIM
To write a program to develop windows based installation file with Student Registration
form and Login form using database access.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click Open.

Step 2: Open two forms and design the login and registration form using necessary
components such as Labels, Command buttons, Textboxes for both forms and
place the data control in registration form. .

Step 3: Change the property legends for necessary components.

Step 4: Develop the source code by selecting components with suitable events to display
the saved file.

Step 5: Create the database using database access for registration form.

Step 6: Using Data control to connect the object with the database.

Step 7: Save and execute the project.


FORM DESIGN: LOGIN FORM

PROPERTY LEGENDS FOR LOGIN FORM

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Login Form

Label2 Label2 User name

Label3 Label3 Password


Text1 Text1

Text2 Text2

Command1 cmdlogin Login

Command2 cmdreset Reset


REGISTRATION FORM

PROPERTY LEGENDS FOR REGISTRATION FORM

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Registration Form

Label2 Label2 Id

Label3 Label3 Name

Label4 Label4 Class

Label5 Label5 Address

Label6 Label6 Phone no


Text1 Text1

Text2 Text2

Text3 Text3

Text4 Text4

Text5 Text5

Text6 Text6

Command1 cmdregister Register

Command2 cmdadd Add New

Command3 cmdcancel Cancel

CODING

LOGIN FORM

Private Sub cmdlogin_Click()


Dim user As String
Dim pass As String
user = "admin"
pass = "admin"
If (user = username.Text and pass = password.Text) Then
MsgBox "Login Successfull"
registration.Show
Else
MsgBox "invalid username or password", vbOKOnly, "login Failed"
End If
End Sub

Private Sub cmdreset_Click()


username.Text = ""
password.Text = ""
End Sub
REGISTRATION FORM

Private Sub cmdregister_Click()

Data1.Recordset.Update

MsgBox "Register Successfully"

End Sub

Private Sub cmdadd_Click()

Data1.Recordset.AddNew

End Sub

Private Sub cmdcancel_Click()

Id.Text = ""

Name.Text = ""

Class.Text = ""

Address.Text = ""

Phoneno.Text = ""

End Sub
OUTPUT
RESULT

Thus the above program to develop Student Registration form and Login form using
database access has been executed successfully.
EX NO: 8 DATABASE USING ADO

DATE:

AIM
To insert, update, delete a Record in database using ADO.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click Open.

Step 2: Design the form using necessary components such as Labels, Textboxes and
Command buttons.

Step 3: Change the property legends for necessary components.

Step 4: Develop the source code by selecting components with suitable events to insert,
update and delete a records.

Step 5: Create the database for registration form using Microsoft office Access.

Step 6: Using Ado (ActiveX Data Object) control to connect the object with the database.

Step 7: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS FOR LOGIN FORM

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Database using Ado


Label2 Label2 Id
Label3 Label3 Name
Label4 Label4 DOB
Label5 Label5 Designation
Label6 Label6 Department
Label7 Label7 Phone no
Text1 Text1
Text2 Text2
Text3 Text3
Text4 Text4
Text5 Text5
Text6 Text6
Command1 cmdadd Add
Command2 cmdupdate Update
Command3 cmddelete Delete
Command4 cmdexit Exit
Command5 cmdprevious Move Previous
Command6 cmdnext Move Next
Command7 cmdfirst Move First
Command8 cmdlast Move Last
Adodc Adodc1 Adodc1

CODING
Private Sub cmdadd_Click()
Adodc1.Recordset.AddNew
End Sub

Private Sub cmdupdate_Click()


Adodc1.Recordset.update
MsgBox "Record updated"
End Sub
Private Sub cmddelete_Click()
Adodc1.Recordset.delete
MsgBox "Record deleted"
End Sub

Private Sub cmdexit_Click()


End
End Sub

Private Sub cmdprevious_Click()

Adodc1.Recordset.MovePrevious
End Sub

Private Sub cmdnext_Click()


Adodc1.Recordset.MoveLast
End Sub

Private Sub cmdfirst_Click()


Adodc1.Recordset.MoveFirst
End Sub

Private Sub cmdlast_Click()

Adodc1.Recordset.MoveLast
End Sub
OUTPUT

RESULT

Thus the above program to insert, update, delete a Record in database using ADO has
been executed successfully.
EX NO: 9 PERSONAL INFORMATION SYSTEM

DATE:

AIM
To implement Personal Information System using MDI and Standard ADODC controls
and reports.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click Open.

Step 2: Design the form using necessary components such as Labels, Textboxes,
Command buttons and Adodc control.

Step 3: Change the property legends for necessary components.

Step 4: Develop the source code by selecting components with suitable events to display
the saved file and change data properties on property form.

Step 5:Create the database for personal information system using Microsoft office Access.

Step 6: Using Ado(ActiveX Data Object) control to connect the object with the database.

Step 7: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS FOR LOGIN FORM

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Personal Information System


Label2 Label2 Name
Label3 Label3 DOB
Label4 Label4 Blood Group
Label5 Label5 Address
Label6 Label6 Phone no
Label7 Label7 E-Mail
Text1 Text1
Text2 Text2
Text3 Text3
Text4 Text4

Text5 Text5
Text6 Text6
Command1 cmdadd Add
Command2 cmdupdate Update
Command3 cmddelete Delete
Command4 cmdexit Exit

Command5 cmdprevious Move Previous


Command6 cmdnext Move Next
Command7 cmdfirst Move First
Command8 cmdlast Move Last
Adodc Adodc1 Adodc1

CODING

Private Sub cmdadd_Click()


Text1.SetFocus
Data1.Recordset.AddNew
End Sub

Private Sub cmdupdate_Click()


Adodc1.Recordset.update
MsgBox "Record updated"
clear
End Sub
Private Sub cmddelete_Click()
Adodc1.Recordset.delete
MsgBox "Record deleted"
End Sub

Private Sub cmdexit_Click()


End
End Sub

Private Sub cmdprevious_Click()

Adodc1.Recordset.MovePrevious
End Sub

Private Sub cmdnext_Click()


Adodc1.Recordset.MoveLast
End Sub

Private Sub cmdfirst_Click()


Adodc1.Recordset.MoveFirst
End Sub

Private Sub cmdlast_Click()

Adodc1.Recordset.MoveLast
End Sub
OUTPUT

RESULT

Thus the implement Personal Information System using MDI and Standard ADODC
controls and reports has been executed successfully.
EX NO:10 ANIMATION USING TIMERS

DATE :

AIM
To implement animation using timers.

PROCEDURE

Step 1: Open Visual Basic 6.0, Select Standard Exe from the New Project Dialog Box
and click Open.

Step 2: Place the timer and give the interval 1.

Step 3: Create command button to move the image and stop the image.

Step 4: Create the database for registration form.

Step 5: Develop the source code by selecting components with suitable events to display
the animation.

Step 6: Save and execute the project.


FORM DESIGN

PROPERTY LEGENDS

CONTROL NAME NAME PROPERTY CAPTION PROPERTY

Label1 Label1 Animation using timer

Image Image1

Command1 cmdstart Start

Command2 cmdstop Stop


CODING

Private Sub cmdstart_Click()

Timer1.Enabled = True

End Sub

Private Sub stop_Click()

Timer1.Enabled = False

End Sub

Private Sub Form_Load()

Timer1.Enabled = False

End Sub

Private Sub Timer1_Timer()

Image1.Left = Image1.Left + 10

If Image1.Left >= 2600 Then

Image1.Top = Image1.Top - 10

Image1.Left = Image1.Left + 10

End If

End Sub
OUTPUT

RESULT

Thus the implement animation using timers has been executed successfully.

You might also like