Programming in visual Basic Subject Code:SAE51
CHEVALIER T. THOMAS ELIZABETH
COLLEGE FOR WOMEN
No. 16, St. Mary’s Road, Sembium, Chennai – 600 011.
E-Mail : [email protected]
B.SC COMPUTER SCIENCE
LAB MANUALS
Chevalier T.Thomas College For Woman
Department of Computer Science Page 1
Programming in visual Basic Subject Code:SAE51
Chevalier T.Thomas College For Woman
Department of Computer Science Page 2
Programming in visual Basic Subject Code:SAE51
S.NO NAME OF THE PROGRAM PAGE NO
4
1. PAYROLL PROCESSING SYSTEM
10
2. MARKSHEET PROCESSING
18
3. SAVING BANK ACCOUNT PROCESSING
28
4. INVENTORY SYSTEM
36
5. INVOICE PREPARATION SYSTEM
44
6. LIBRARY INFORMATION SYSTEM
54
7. STUDENT INFORMATION SYSTEM
62
8. INCOME TAX PROCESSING SYSTEM
73
9. ELECTRICITY BILL PREPARATION
85
10. TELEPHONE DIRECTORY MAINTENANCE
Chevalier T.Thomas College For Woman
Department of Computer Science Page 3
Programming in visual Basic Subject Code:SAE51
Ex. No : 1 PAYROLL PROCESSING SYSTEM
AIM:
To design a menu driven for creating a database and performing operation like
insertion,deletion,modification for payroll processing.
TABLE DESCRIPTION:
S.NO FIELD SIZE DATATYPE DESCRIPTION
NAME
1 Empid 20 Varchar2 Specifies Empid of person
2 Name 20 Varchar2 Specifies name of person
3 Designation 20 Varchar2 Specifies designation of person
4 Basic pay 20 Varchar2 Specifies Basic pay of person
5 Allowance 20 Varchar2 Specifies Allowance pay amount of person
6 Deduction 20 Varchar2 Specifies deduction amount of person
7 Gross pay 20 Varchar2 Specifies Gross pay amount of person
8 Net pay 20 Varchar2 Specifies net pay amount of person
SOURCE CODE:
CODING FOR MDI FORM
Private Sub exit_Click()
Unload Me
End Sub
Private Sub process_Click()
Form1.Show
End Sub
Private Sub view_Click()
Form2.Show
End Sub
CODING FOR FORM1
Chevalier T.Thomas College For Woman
Department of Computer Science Page 4
Programming in visual Basic Subject Code:SAE51
Private Sub Combo1_Click()
If Combo1.Text = "Grade A" Then
Text3.Text = 20000
ElseIf Combo1.Text = "Grade B" Then
Text3.Text = 15000
ElseIf Combo1.Text = "Grade C" Then
Text3.Text = 10000
End If
End Sub
Private Sub Command1_Click()
If Combo1.Text = "Grade A" Then
Text4.Text = Val(Text3.Text) * 20 / 100
Text5.Text = Val(Text3.Text) * 15 / 100
ElseIf Combo1.Text = "Grade B" Then
Text4.Text = Val(Text3.Text) * 10 / 100
Text5.Text = Val(Text3.Text) * 8 / 100
ElseIf Combo1.Text = "Grade C" Then
Text4.Text = Val(Text3.Text) * 5 / 100
Text5.Text = Val(Text3.Text) * 2 / 100
End If
End Sub
Private Sub Command10_Click()
Adodc1.Recordset.MoveLast
End Sub
Private Sub Command2_Click()
If Combo1.Text = "Grade A" Then
Text6.Text = Val(Text3.Text) + Val(Text4.Text)
Chevalier T.Thomas College For Woman
Department of Computer Science Page 5
Programming in visual Basic Subject Code:SAE51
Text7.Text = Val(Text3.Text) - Val(Text4.Text)
ElseIf Combo1.Text = "Grade B" Then
Text6.Text = Val(Text3.Text) + Val(Text4.Text)
Text7.Text = Val(Text3.Text) - Val(Text4.Text)
ElseIf Combo1.Text = "Grade C" Then
Text6.Text = Val(Text3.Text) + Val(Text4.Text)
Text7.Text = Val(Text3.Text) - Val(Text4.Text)
End If
End Sub
Private Sub Command3_Click()
Adodc1.Recordset.AddNew
End Sub
Private Sub Command4_Click()
MsgBox "you can update now"
End Sub
Private Sub Command5_Click()
Adodc1.Recordset.Update
MsgBox "your record is saved"
End Sub
Private Sub Command6_Click()
Adodc1.Recordset.Delete
MsgBox "The record is deleted"
Adodc1.Recordset.MoveLast
End Sub
Private Sub Command7_Click()
Adodc1.Recordset.MoveFirst
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 6
Programming in visual Basic Subject Code:SAE51
Private Sub Command8_Click()
If Adodc1.Recordset.BOF Then
MsgBox "You are in first record"
Else
Adodc1.Recordset.MovePrevious
End If
End Sub
Private Sub Command9_Click()
If Adodc1.Recordset.EOF Then
MsgBox "You are in last record"
Else
Adodc1.Recordset.MoveNext
End If
End Sub
OUTPUT:
PAYROLL PROCESSING
MDI FORM:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 7
Programming in visual Basic Subject Code:SAE51
FORM 1 : PAYROLL PROCESSING:
FORM 2: PAYROLL VIEW:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 8
Programming in visual Basic Subject Code:SAE51
PAYROLL REPORT:
RESULT:
Thus,the table created using MS-access has been developed for payroll processing
system and insert,delete and update operation has been performed in VB.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 9
Programming in visual Basic Subject Code:SAE51
Ex. No : 2 MARKSHEET PROCESSING SYSTEM
AIM:
To design a menu editor driven application for marksheet processing system and to
perform insertion,deletion and modification using visual basic and MS access.
TABLE DESCRIPTION:
S.NO FIELD SIZ DATATYPE DESCRIPTION
NAME E
1 Register 10 Text Specifies the Register Number
Number
2 Name 30 Text Specifies the Name
3 Department 10 Text Specifies the Department
4 Year 10 Text Specifies the Year
5 Semester 10 Number Specifies the Semester
6 Sub1 10 Number Specifies the Subject1
7 Sub2 10 Number Specifies the Subject2
8 Sub3 10 Number Specifies the Subject3
9 Sub4 10 Number Specifies the Subject4
10 Total 30 Number Specifies the Total
11 Average 20 Number Specifies the Average
12 Result 20 Text Specifies the Result
13 Grade 20 Text Specifies the Grade
SOURCE CODE:
CODING FOR MDI FORM
Dim RES, DEPT1 As String
Dim RNO As Long
CODING FOR EXIT
Private Sub EXIT_Click()
Unload Me
End Sub
CODING FOR MDIFORM LOAD
Private Sub MDIForm_Load()
Chevalier T.Thomas College For Woman
Department of Computer Science Page 10
Programming in visual Basic Subject Code:SAE51
MDIForm1.WindowState = 2
End Sub
CODING FOR DEPARTMENT WISE REPORT
Private Sub MNUDEPT_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
DEPT1 = InputBox("Enter the Department Name")
DataEnvironment1.rsCommand1.Open ("Select * from mark_iiibsc where
upper(department) = '" &UCase(DEPT1) & "'")
DataReport3.Show
End Sub
CODING FOR REGISTER NO. WISE REPORT
Private Sub MNUMARK_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
RNO = InputBox("Enter the Register No. to view the marksheet")
DataEnvironment1.rsCommand1.Open ("Select * from mark_iiibsc
where regno =" &Val(RNO))
DataReport2.Show
End Sub
CODING FOR RESULT WISE REPORT
Private Sub MNURES_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
RES = InputBox("Enter the Result category(PASS/FAIL)")
DataEnvironment1.rsCommand1.Open ("Select * from mark_iiibsc
where upper(result) = '" &UCase(RES) & "'")
Chevalier T.Thomas College For Woman
Department of Computer Science Page 11
Programming in visual Basic Subject Code:SAE51
DataReport1.Show
End Sub
CODING FOR FORM1
Private Sub PROCESSING_Click()
Form1.Show
End Sub
CODING FOR FORM2
Private Sub VIEW_Click()
Form2.Show
End Sub
CODING FOR FORM1
CODING FOR CALCULATION
Private Sub cmdPROCESSOR_Click()
Text8.Text = Val(Text4.Text) + Val(Text5.Text)
+ Val(Text6.Text) + Val(Text7.Text)
Text9.Text = (Text8.Text) / 4
If ((Text4.Text < 40) Or (Text5.Text < 40) Or
(Text6.Text < 40) Or (Text7.Text < 40)) Then
Text10.Text = "FAIL"
Else
Text10.Text = "PASS"
End If
If (Text9.Text >= 80) Then
Text11.Text = "FRIST CLASS"
ElseIf ((Text9.Text >= 60) And (Text9.Text < 80)) Then
Text11.Text = "SECOND CLASS"
ElseIf ((Text9.Text >= 40) And (Text9.Text < 60)) Then
Chevalier T.Thomas College For Woman
Department of Computer Science Page 12
Programming in visual Basic Subject Code:SAE51
Text11.Text = "THIRD CLASS"
End If
If (Text10.Text = "FAIL") Then
Text11.Text = "FAIL"
End If
End Sub
CODING TO ADD ITEM IN COMBO1
Private Sub Combo1_Click()
If Combo1.Text = "1" Then
Combo2.AddItem "I"
Combo2.AddItem "II"
ElseIf Combo1.Text = "2" Then
Combo2.AddItem "III"
Combo2.AddItem "IV"
ElseIf Combo1.Text = "3" Then
Combo2.AddItem "V"
Combo2.AddItem "VI"
End If
End Sub
CODING FOR ADD
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
MsgBox "you can add a new record now"
End Sub
CODING FOR EDIT
Private Sub Command2_Click()
MsgBox "you can edit now"
Chevalier T.Thomas College For Woman
Department of Computer Science Page 13
Programming in visual Basic Subject Code:SAE51
End Sub
CODING FOR UPDATE
Private Sub Command3_Click()
Adodc1.Recordset.Update
MsgBox "your record is saved"
End Sub
CODING FOR DELETE
Private Sub Command4_Click()
Adodc1.Recordset.Delete
MsgBox "your record is deleted"
End Sub
CODING FOR MOVE FIRST
Private Sub Command5_Click()
Adodc1.Recordset.MoveFirst
End Sub
CODING FOR MOVE PREVIOUS
Private Sub Command6_Click()
If Adodc1.Recordset.BOF Then
MsgBox" you are in the first record, there is no previous record"
Adodc1.Recordset.MoveFirst
Else
Adodc1.Recordset.MovePrevious
End If
End Sub
CODING FOR MOVE NEXT
Private Sub Command7_Click()
If Adodc1.Recordset.EOF Then
Chevalier T.Thomas College For Woman
Department of Computer Science Page 14
Programming in visual Basic Subject Code:SAE51
MsgBox" you are in the last record, there is no next record"
Adodc1.Recordset.MoveLast
Else
Adodc1.Recordset.MoveNext
End If
End Sub
CODING FOR MOVE LAST
Private Sub Command8_Click()
Adodc1.Recordset.MoveLast
End Sub
CODING FOR SEARCH
Private Sub Command9_Click()
a = Val(InputBox("enter a register no"))
Adodc1.Recordset.MoveFirst
Do Until Adodc1.Recordset.EOF
If Adodc1.Recordset.Fields(0) = a Then
MsgBox "record found"
GoTo a
End If
Adodc1.Recordset.MoveNext
Loop
MsgBox "STUDENT NOT FOUND"
a:
End Sub
CODING FOR FORM LOAD
Private Sub Form_Load()
Form1.WindowState = 2
Chevalier T.Thomas College For Woman
Department of Computer Science Page 15
Programming in visual Basic Subject Code:SAE51
End Sub
OUTPUT:
MARKSHEET PROCESSING
MDI FORM:
FORM 1 : MARKSHEET PROCESSING:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 16
Programming in visual Basic Subject Code:SAE51
FORM 2: MARKSHEET VIEW:
REPORT 1: MARKSHEET REPORT:
RESULT:
Thus,the table has been created by using MS-access for marksheet processing and
insert,delete and update operation has been performed.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 17
Programming in visual Basic Subject Code:SAE51
Ex. No : 3 Saving Bank Account Processing
AIM:
To design a menu driven program for a database application like insertion, deletion,
modification and generate a report for banking processing system.
TABLE DESCRIPTION(BANKING):
S.NO FIELD NAME SIZE DATATYPE DESCRIPTION
1 Accno 10 Number Specifies accno of person
2 Opendate Date Specifies open date
3 Cheque 6 Varchar2 Specifies cheque
4 ATM 6 Varchar2 Specifies ATM
5 Initialdeposit 10 Number Specifies initial deposit amount
6 Currbalance 10 Number Specifies the curr balance
7 Custname 10 Varchar2 Specifies customer name
8 DOB 6 Date Specifies DOB of person
9 Gender 6 Varchar2 Specifies gender of person
10 Fathername 10 Varchar2 Specifies father name of person
11 Mothername 10 Varchar2 Specifies mother name of person
12 Nationality 10 Varchar2 Specifies nationality of person
13 Mobile 10 Number Specifies mobile of person
14 Email 10 Varchar2 Specifies email of person
15 Address 20 Varchar2 Specifies address of person
16 City 20 Varchar2 Specifies city of person
TABLE DESCRIPTION:
S.NO FIELD SIZE DATATYPE DESCRIPTION
NAME
1 Transno 10 Number Specifies transno of person
2 Transdate 10 Date Specifies transdate of person
3 Accno 10 Varchar2 Specifies accno of person
4 Transtype 6 Varchar2 Specifies transtype of person
5 Transmode 6 Varchar2 Specifies transmode of person
6 Custname 10 Varchar2 Specifies customername of person
7 Prevbal 6 Number Specifies prev balance of person
8 Transamt 6 Number Specifies transamt of person
9 newbalance 6 Number Specifies new balance of person
Chevalier T.Thomas College For Woman
Department of Computer Science Page 18
Programming in visual Basic Subject Code:SAE51
SOURCE CODE:
FORM1
Dim no As Integer
Private Sub Command1_Click()
MsgBox Adodc1.Recordset.RecordCount
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveLast
no = Adodc1.Recordset.Fields(0) + 1
Else
no = 1
End If
Adodc1.Recordset.AddNew
Text7 = Date
Text1 = no
End Sub
Private Sub Command2_Click()
MsgBox "You can Edit Now"
End Sub
Private Sub Command3_Click()
If Option2.Value = True Then
Adodc1.Recordset.Fields(4) = "Yes"
Else
Adodc1.Recordset.Fields(4) = "No"
End If
If Option4.Value = True Then
Adodc1.Recordset.Fields(5) = "Yes"
Else
Chevalier T.Thomas College For Woman
Department of Computer Science Page 19
Programming in visual Basic Subject Code:SAE51
Adodc1.Recordset.Fields(5) = "No"
End If
Adodc1.Recordset.Update
MsgBox ("The Customer is Updated")
End Sub
Private Sub Command4_Click()
Adodc1.Recordset.Delete
MsgBox ("your record has deleted")
End Sub
Private Sub Command5_Click()
Adodc1.Recordset.MoveFirst
'MsgBoxAdodc1.Recordset.Fields()
Displayopt
End Sub
Private Sub Command6_Click()
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
MsgBox "This is the First Customer"
End If
Displayopt
End Sub
Private Sub Command7_Click()
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
MsgBox "This is the Last Customer"
Adodc1.Recordset.MoveLast
Chevalier T.Thomas College For Woman
Department of Computer Science Page 20
Programming in visual Basic Subject Code:SAE51
End If
Displayopt
End Sub
Private Sub Command8_Click()
Adodc1.Recordset.MoveLast
Displayopt
End Sub
Private Sub Form_Load()
WindowState = 2
End Sub
Public Sub Displayopt()
If Adodc1.Recordset.Fields(4) = "Yes" Then
Option2.Value = True
Option3.Value = False
Else
Option2.Value = False
Option3.Value = True
End If
If Adodc1.Recordset.Fields(5) = "Yes" Then
Option4.Value = True
Option5.Value = False
Else
Option4.Value = False
Option5.Value = True
End If
End Sub
form2
Chevalier T.Thomas College For Woman
Department of Computer Science Page 21
Programming in visual Basic Subject Code:SAE51
Private Sub Combo1_Click()
If Combo1.Text = "Deposit" Then
Text7.Text = Val(Text4.Text) + Val(Text6.Text)
Else
Text7.Text = Val(Text4.Text) - Val(Text6.Text)
End If
End Sub
Private Sub Command3_Click()
Adodc2.Recordset.AddNew
Text3.Text = Date
End Sub
Private Sub Command4_Click()
Adodc2.Recordset.Fields(0) = Val(Text1)
Adodc2.Recordset.Fields(2) = Val(Text4)
Adodc2.Recordset.Fields(6) = Text2
Adodc1.Recordset.Fields(9) = Val(Text7)
Adodc1.Recordset.Update
Adodc2.Recordset.Update
End Sub
Private Sub Command6_Click()
Adodc2.Recordset.Delete
MsgBox ("Your record is deleted")
Adodc2.Recordset.MoveNext
End Sub
Private Sub Form_Load()
Text3 = Date
WindowState = 2
Chevalier T.Thomas College For Woman
Department of Computer Science Page 22
Programming in visual Basic Subject Code:SAE51
End Sub
Private Sub Text1_Change()
If Adodc1.Recordset.State = 1 Then Adodc1.Recordset.Close
Adodc1.Recordset.Open ("select * from bank_iiibsc where acno = " &Val(Text1.Text))
'MsgBoxAdodc1.Recordset.Fields(1)
Adodc1.Recordset.Requery
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Adodc1.Recordset.State = 1 Then Adodc1.Recordset.Close
Adodc1.Recordset.Open ("select * from bank_iiibsc where acno = " &Val(Text1.Text))
MsgBoxAdodc1.Recordset.Fields(1)
Adodc1.Recordset.Requery
End If
'/.Fields(1)
Adodc1.Recordset.MoveFirst
Do Until Adodc1.Recordset.EOF
If Adodc1.Recordset.Fields(0) = Val(Text1) Then
Text2 = Adodc1
End Sub
MDI FORM
Dim acno As Integer
Dim custname As String
Private Sub MDIForm_Load()
MDIForm1.WindowState = 2
End Sub
Private Sub menuaccopen_Click()
Chevalier T.Thomas College For Woman
Department of Computer Science Page 23
Programming in visual Basic Subject Code:SAE51
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
End If
custname = InputBox("enter the customername to view the amount")
DataEnvironment1.rsCommand1.Open ("select * from bank_iiibsc where name='"
&custname& "'")
DataReport3.Show
End Sub
Private Sub menubot_Click()
If DataEnvironment1.rsCommand2.State = 1 Then
DataEnvironment1.rsCommand2.Close
End If
acno = InputBox("enter the acno to view the amount")
DataEnvironment1.rsCommand2.Open ("select * from banktrans_iiibsc where acno="
&Val(acno))
DataReport4.Show
End Sub
Private Sub menuexit_Click()
Unload Me
End Sub
Private Sub menuprocess_Click()
Form1.Show
End Sub
Private Sub menutrans_Click()
Form3.Show
End Sub
Private Sub menuview_Click()
Chevalier T.Thomas College For Woman
Department of Computer Science Page 24
Programming in visual Basic Subject Code:SAE51
Form2.Show
End Sub
OUTPUT:
SAVINGS BANK ACCOUNT:
MDI FORM
FORM 1: CUSTOMER DETAILS:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 25
Programming in visual Basic Subject Code:SAE51
FORM 2: TRANSACTION DETAILS:
REPORT:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 26
Programming in visual Basic Subject Code:SAE51
RESULT:
Thus an table has been created by using MS-Access for saving bank account and
insertion,deletion,modification and generating a report has been performed in VB.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 27
Programming in visual Basic Subject Code:SAE51
Ex. No : 4 Inventory System
AIM:
To write a menu driven program for performing inventory management system.
TABLE DESCRIPTION (INVENTORY):
S.NO FIELD SIZE DATATYPE DESCRPITION
NAME
1 Icode 10 Varchar2 Specifies the item code
2 Gcode 10 Varchar2 Specifies the group code
3 Iname 20 Varchar2 Specifies the item name
4 Cpu 10 Number Specifies the cost per unit
5 Sp 10 Number Specifies the sale price
6 Quantityhand 10 Number Specifies the quantity in hand
7 reo 10 Number Specifies the recorder level
TABLE DESCRPITION (TRANSACTION):
S.NO FIELD SIZE DATATYPE DESCRPITION
NAME
1 Date date Specifies the date of transaction
2 Tid 10 Number Specifies the trans id
3 Tmode 10 Varchar2 Specifies the trans mode
4 Icode 10 Varchar2 Specifies the item code
5 Quantity 10 Number Specifies the quantity of item
6 Qoh 10 Number Specifies the quantity in hand
7 amt 10 Number Specifies the amount of item
SOURCE CODE:
CODING FOR MDI FORM:
DECLARATION STATEMENT:
Dim grou As String
Dim reor As Integer
CODING FOR REORDER LEVEL:
Private Sub de_Click()
Chevalier T.Thomas College For Woman
Department of Computer Science Page 28
Programming in visual Basic Subject Code:SAE51
If DataEnvironment1.rsCommand1.State = 1 Then DataEnvironment1.
rsCommand1.Close
reor = InputBox("Enter the reorder level ")
DataEnvironment1.rsCommand1.Open ("select * from inven1 where
qhan<= " & Val(reor))
DataReport3.Show
End Sub
CODING FOR EXIT:
Private Sub exit_Click()
Unload Me
End Sub
CODING FOR GROUPCODE:
Private Sub gro_Click()
If DataEnvironment1.rsCommand1.State = 1 Then DataEnvironment1.
rsCommand1.Close
grou = InputBox("Enter the group code ")
DataEnvironment1.rsCommand1.Open ("select * from inven1 where
gcode= '" &grou& "'")
DataReport2.Show
End Sub
CODING FOR FORM1:
Private Sub pro_Click()
Form1.Show
End Sub
CODING TO VIEW ALL DETAILS:
Private Sub reo_Click()
If DataEnvironment1.rsCommand1.State = 1 Then DataEnvironment1
Chevalier T.Thomas College For Woman
Department of Computer Science Page 29
Programming in visual Basic Subject Code:SAE51
.rsCommand1.Close
DataEnvironment1.rsCommand1.Open ("select * from inven1")
DataReport1.Show
End Sub
CODING FOR FORM2:
Private Sub view_Click()
Form2.Show
End Sub
CODING FOR FORM1:
CODING FOR ADD NEW ITEM:
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
provisi1
Text9 = Date
Text10 = Time
End Sub
CODING FOR DELETE ITEM:
Private Sub Command2_Click()
provisi1
Adodc1.Recordset.Delete
MsgBox" item deleted "
Adodc1.Recordset.MovePrevious
End Sub
CODING FOR SAVE:
Private Sub Command3_Click()
Adodc1.Recordset.Update
provisi1
Chevalier T.Thomas College For Woman
Department of Computer Science Page 30
Programming in visual Basic Subject Code:SAE51
Text9 = Date
Text10 = Time
MsgBox " Record Saved "
End Sub
CODING FOR EDIT:
Private Sub Command4_Click()
provisi1
MsgBox "Now you can Update the Detaails "
End Sub
CODING FOR MOVEFIRST:
Private Sub Command5_Click()
Adodc1.Recordset.MoveFirst
provisi1
End Sub
CODING FOR MOVE PREVIOUS:
Private Sub Command6_Click()
provisi1
If Adodc1.Recordset.BOF Then
MsgBox "You are in the first record "
Adodc1.Recordset.MoveFirst
Else
Adodc1.Recordset.MovePrevious
End If
End Sub
CODING FOR MOVENEXT:
Private Sub Command7_Click()
provisi1
Chevalier T.Thomas College For Woman
Department of Computer Science Page 31
Programming in visual Basic Subject Code:SAE51
If Adodc1.Recordset.EOF Then
MsgBox "You are in the last record "
Adodc1.Recordset.MoveLast
Else
Adodc1.Recordset.MoveNext
End If
End Sub
CODING FOR MOVELAST:
Private Sub Command8_Click()
provisi1
Adodc1.Recordset.MoveLast
End Sub
CODING FOR PURCHASE:
Private Sub Option1_Click()
Label8.Visible = False
Text6.Visible = False
Label9.Visible = True
Text7.Visible = True
End Sub
CODING FOR SALE:
Private Sub Option2_Click()
Label8.Visible = True
Text6.Visible = True
Label9.Visible = False
Text7.Visible = False
End Sub
CODING FOR SALE ITEM:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 32
Programming in visual Basic Subject Code:SAE51
Private Sub Text6_LostFocus()
Text4 = Val(Text4.Text) - Val(Text6.Text)
If Val(Text4.Text) <= 50 Then
MsgBox" Please reorder the items "
End If
End Sub
CODING FOR PURCHARSE ITEM:
Private Sub Text7_LostFocus()
Text4 = Val(Text4.Text) + Val(Text7.Text)
End Sub
CODING FOR PROCEDURE ‘PROVISI1’:
Public Sub provisi1()
Label8.Visible = True
Text6.Visible = True
Label9.Visible = True
Text7.Visible = True
End Sub
CODING FOR REQUERY:
Private Sub Form_Load()
Adodc1.Recordset.Requery
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 33
Programming in visual Basic Subject Code:SAE51
OUTPUT:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 34
Programming in visual Basic Subject Code:SAE51
RESULT:
Thus an table created using MS-Access has been developed for inventory system.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 35
Programming in visual Basic Subject Code:SAE51
Ex. No : 5 Invoice System
AIM:
To design a menu driven program for a database application like
insertion,deletion,modification and to generate report for invoice processing system.
TABLE DESCRPITION:
S.NO FIELD SIZE DATATYPE DESCRPITION
NAME
1 Ordered 10 Number Specifies order id
2 Date 10 Date Specifies the date
3 Empid 10 Text Specifies the employee id
4 Customerna 10 Text Specifies the customer name
me
5 Itemcode 15 Number Specifies the item code
6 Itemname 15 Text Specifies the item name
7 Listprice 10 Number Specifies the list of price
8 Quantity 10 Number Specifies the quantity
9 Price 10 Number Specifies the price
10 Discount (5-2) Number Specifies the discount
11 Amount to (10-2) Number specifies the amount to pay
pay
12 paymode 15 text Specifies the pay mode
SOURCE CODE:
CODING FOR MDIFORM
Dim orno As Integer
Private Sub exit_Click()
Unload Me
End Sub
Private Sub mnuinvoice_Click()
Form1.Show
End Sub
Private Sub mnuview_Click()
Chevalier T.Thomas College For Woman
Department of Computer Science Page 36
Programming in visual Basic Subject Code:SAE51
Form2.Show
End Sub
Private Sub mnubill_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
End If
orno = InputBox("Enter the Order No: ")
DataEnvironment1.rsCommand1.Open ("select * from (ordercr inner join
saleitem on ordercr.orderid = saleitem.orderno) inner join
inbillcr on saleitem.orderno = inbillcr.orderid where orderid =
'" &orno& "'")
If DataEnvironment1.rsCommand1.RecordCount = 0 Then
MsgBox "No record selected"
Else
MsgBoxDataEnvironment1.rsCommand1.Fields(2)
DataReport1.Sections("Section4").Controls.Item("lbloid").Caption
= "Order No : " &orno
DataReport1.Sections("Section4").Controls.Item("lblodate").Caption
= "Order Date : " & DataEnvironment1.rsCommand1.Fields(2)
DataReport1.Sections("Section4").Controls.Item("lblcname").Caption
= "Customer Name : " & DataEnvironment1.rsCommand1.Fields(1)
DataReport1.Sections("Section4").Controls.Item("lbleid").Caption
= "Employee ID : " & DataEnvironment1.rsCommand1.Fields(3)
DataReport1.Sections("Section5").Controls.Item("lblpayamt").Caption
= "Bill Amount : " & DataEnvironment1.rsCommand1.Fields(14)
DataReport1.Sections("Section5").Controls.Item("lblmode").Caption
= "Payment Mode : " & DataEnvironment1.rsCommand1.Fields(15)
Chevalier T.Thomas College For Woman
Department of Computer Science Page 37
Programming in visual Basic Subject Code:SAE51
DataReport1.Show
End If
End Sub
CODING FOR FORM1
Dim amt As Double
Dim rcount As Integer
Dim no, i As Integer
Private Sub cbitem_Click()
If Adodc1.Recordset.State = 1 Then Adodc1.Recordset.Close
Adodc1.Recordset.Open ("select * from itemcr1 where icode
='" &cbitem.Text& "'")
txtiname.Text = Adodc1.Recordset.Fields(2)
txtprice.Text = Adodc1.Recordset.Fields(6)
End Sub
Private Sub cmdnew_Click()
If Adodc2.Recordset.RecordCount > 0 Then
Adodc2.Recordset.MoveLast
no = Adodc2.Recordset.Fields(0) + 1
Else
no = 1001
End If
Adodc2.Recordset.AddNew
txtdate = Date
txtoid = no
cmddel.Visible = True
End Sub
Private Sub txtamt_lostfocus()
Chevalier T.Thomas College For Woman
Department of Computer Science Page 38
Programming in visual Basic Subject Code:SAE51
If Val(txtamt.Text) >= 5000 Then
txtdis.Text = Val(txtamt.Text) * 25 / 100
ElseIfVal(txtamt.Text) >= 3000 And Val(txtamt.Text) < 5000 Then
txtdis.Text = Val(txtamt.Text) * 20 / 100
ElseIfVal(txtamt.Text) >= 2000 And Val(txtamt.Text) < 3000 Then
txtdis.Text = Val(txtamt.Text) * 15 / 100
ElseIfVal(txtamt.Text) >= 1000 And Val(txtamt.Text) < 2000 Then
txtdis.Text = Val(txtamt.Text) * 10 / 100
Else
txtdis.Text = Val(txtamt.Text) * 5 / 100
End If
txtamtpay = Val(txtamt.Text) - Val(txtdis.Text)
End Sub
Private Sub cmddel_Click()
Adodc2.Recordset.Delete
MsgBox "Order Cancelled"
End Sub
Private Sub cmdiadd_Click()
Adodc3.Recordset.AddNew
txtord.Text = txtoid.Text
cmddel.Visible = False
End Sub
Private Sub cmdirem_Click()
rcount = Adodc3.Recordset.RecordCount
Adodc3.Recordset.Delete
MsgBox "Item removed from list"
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 39
Programming in visual Basic Subject Code:SAE51
Private Sub cmdisave_Click()
Adodc3.Recordset.Update
flexdisplay.AddItem (txtiname.Text&vbTab&txtqty.Text&vbTab&
txtamt.Text&vbTab&txtdis.Text&vbTab&txtamtpay.Text)
MsgBox "Item added to list"
amt = amt + CDbl(txtamtpay.Text)
txtbillamt.Text = Str$(amt)
End Sub
Private Sub cmdsave_Click()
Adodc2.Recordset.Update
MsgBox "Order Created"
Adodc4.Recordset.AddNew
txtono.Text = txtoid.Text
End Sub
Private Sub cmdupdate_Click()
Adodc4.Recordset.Update
MsgBox "Order Updated"
flexdisplay.Clear
flexdisplay.Rows = 1
amt = 0
End Sub
private Sub Form_Load()
For i% = 0 To Adodc1.Recordset.RecordCount - 1
cbitem.AddItemAdodc1.Recordset.Fields(0)
Adodc1.Recordset.MoveNext
Next i
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 40
Programming in visual Basic Subject Code:SAE51
Private Sub txtqty_LostFocus()
txtamt.Text = Val(txtqty.Text) * Val(txtprice.Text)
End Sub
OUTPUT:
INVOICE SYSTEM
MAIN FORM 1:
FORM 2: INVOICE PROCESSING:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 41
Programming in visual Basic Subject Code:SAE51
FORM 3: INVOICE LIST:
REPORT : INVOICE REPORT USING ORDER ID.:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 42
Programming in visual Basic Subject Code:SAE51
RESULT:
Thus the table has been created by using MS-Access is developed for invoice system
and insertion,deletion,updation and generating a result has performed in VB.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 43
Programming in visual Basic Subject Code:SAE51
Ex. No : 6 Library Information System
AIM:
To design a menu driven program for the database application and to perform operations
like insertion,deletion and to generate reports for library information system.
TABLE DESCRPITION:
S.NO FIELD NAME SIZE DATATYPE DESCRIPTION
1 BOOKID 10 NUMBER Specifies the book id
2 BOOKNAME 15 TEXT Specifies the book name
3 AUTHOR 10 TEXT Specifies the author
4 PUBLISHER 10 TEXT Specifies the publisher
5 CATEGORY 15 TEXT Specifies the category
6 COSTOFBOOK 10 NUMBER Specifies the cost of book
7 COPIES 10 NUMBER Specifies the copies
TABLE DESCRIPTION:
S.NO FIELD NAME SIZE DATATYPE DESCRIPTION
1 MEMBERID 10 TEXT Specifies the member id
2 MEMBERNAME 10 TEXT Specifies the member name
3 ADDRESS 30 TEXT Specifies the address
4 PHONENO 10 NUMBER Specifies the phone number
5 MEMTYPE 10 NUMBER Specifies the member type
TABLE DESCRIPTION:
S.NO FIELD NAME SIZE DATATYPE DESCRIPTION
1 MEMBERID 10 TEXT Specifies the member id
2 BOOKID 10 TEXT Specifies the book id
3 RETURNDATE 10 TEXT Specifies the return date
4 STATUS 10 NUMBER Specifies the status
SOURCE CODE:
FORM1 CODING
Dim a, stack As Integer
Private Sub aa_Click(PreviousTab As Integer)
Adodc1.Recordset.Requery
Chevalier T.Thomas College For Woman
Department of Computer Science Page 44
Programming in visual Basic Subject Code:SAE51
End Sub
Private Sub Calendar1_Click()
Text13 = Calendar1.Value
End Sub
Private Sub Calendar2_Click()
Text33 = Calendar2.Value
End Sub
CODING FOR COMBO1
Private Sub Combo1_Click()
If Combo1.Text = "STUDENT" Then
Label10.Caption = "Student ID"
Label11.Caption = "Student NAME"
ElseIf Combo1.Text = "STAFF" Then
Label10.Caption = "Staff ID"
Label11.Caption = "Staff NAME"
End If
End Sub
CODING FOR COMBO4
Private Sub Combo4_Click()
If Combo4.Text = "RECIEVED" Then
Text15.Text = Text14 + 1
` ElseIf Combo4.Text = "ISSUED" Then
Text15.Text = Text14 - 1
End If
End Sub
CODING FOR ADDNEW
Private Sub Command1_Click()
Chevalier T.Thomas College For Woman
Department of Computer Science Page 45
Programming in visual Basic Subject Code:SAE51
Adodc1.Recordset.AddNew
End Sub
CODING FOR EDIT
Private Sub Command10_Click()
MsgBox "now you can edit ur record"
End Sub
CODING FOR DELETE
Private Sub Command11_Click()
Adodc3.Recordset.Delete
MsgBox "record is deleted"
End Sub
CODING FOR SAVE
Private Sub Command12_Click()
Adodc2.Recordset.Fields(4) = Val(Text15)
Adodc2.Recordset.Update
Adodc2.Recordset.Requery
Adodc3.Recordset.Fields(0) = Val(Text7.Text)
Adodc3.Recordset.Update
MsgBox "record is saved"
End Sub
Private Sub Command2_Click()
MsgBox "now you can edit ur record"
End Sub
Private Sub Command3_Click()
Adodc1.Recordset.Delete
MsgBox "record is deleted"
Adodc1.Recordset.MovePrevious
Chevalier T.Thomas College For Woman
Department of Computer Science Page 46
Programming in visual Basic Subject Code:SAE51
End Sub
Private Sub Command4_Click()
Text5 = Val(Text6.Text) + Val(Text5.Text)
Adodc1.Recordset.Update
MsgBox "record is saved"
End Sub
Private Sub Command5_Click()
Adodc1.Recordset.MoveFirst
End Sub
Private Sub Command6_Click()
If Adodc1.Recordset.BOF Then
MsgBox" you are in the first record "
Adodc1.Recordset.MoveFirst
Else
Adodc1.Recordset.MovePrevious
End If
End Sub
Private Sub Command7_Click()
If Adodc1.Recordset.EOF Then
MsgBox" you are in the last record "
Adodc1.Recordset.MoveLast
Else
Adodc1.Recordset.MoveNext
End If
End Sub
Private Sub Command8_Click()
Adodc1.Recordset.MoveLast
Chevalier T.Thomas College For Woman
Department of Computer Science Page 47
Programming in visual Basic Subject Code:SAE51
End
Private Sub Command9_Click()
Adodc3.Recordset.AddNew
End Sub
Private Sub Text28_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Adodc3.Recordset.State = 1 Then Adodc3.Recordset.Close
Adodc3.Recordset.Open ("Select * from library_IIIbscb
wheresid = " & Val(Text28.Text))
Adodc3.Recordset.Requery
MsgBoxAdodc2.Recordset.Fields(1)
End If
End Sub
Private Sub Text12_GotFocus()
Text12 = Date
End Sub
Private Sub Text7_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Adodc2.Recordset.State = 1 Then Adodc2.Recordset.Close
Adodc2.Recordset.Open ("Select * from library_IIIbsc
wherebno = " & Val(Text7.Text))
Adodc2.Recordset.Requery
MsgBoxAdodc2.Recordset.Fields(1)
End If
End Sub
Private Sub Text9_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Chevalier T.Thomas College For Woman
Department of Computer Science Page 48
Programming in visual Basic Subject Code:SAE51
If Adodc3.Recordset.State = 1 Then Adodc3.Recordset.Close
Adodc3.Recordset.Open ("Select * from library_IIIbscb
wheresid = '" & Val(Text9.Text) & "'") ' & "and sid = "&Val(Text9.Text))
Adodc3.Recordset.Requery
End If
End Sub
CODING FOR MDI FORM
Dim no As Integer
Private Sub BOOK_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
no = InputBox("Enter the book no:")
DataEnvironment1.rsCommand1.Open ("select * from
library_IIIbsc where bno=" &Val(no))
DataEnvironment1.rsCommand2.Open ("select * from library_iiibscb
where bno=" &Val(no) & "and status='ISSUED'")
DataReport1.Sections(3).Controls(7).Caption =
DataEnvironment1.rsCommand2.RecordCount
DataReport1.Show
End Sub
Private Sub DET_Click()
Form2.Show
End Sub
Private Sub EXIT_Click()
Unload Me
End Sub
Private Sub MDIForm_Load()
Chevalier T.Thomas College For Woman
Department of Computer Science Page 49
Programming in visual Basic Subject Code:SAE51
WindowState = 2
End Sub
Private Sub STATUS_Click()
If DataEnvironment1.rsCommand2.State = 1 Then
DataEnvironment1.rsCommand2.Close
stat = InputBox("Enter the status (RECIEVED/ISSUED):")
DataEnvironment1.rsCommand2.Open ("select * from
library_IIIbscb where status= '" & stat & "' ")
DataReport2.Show
End Sub
Private Sub TRAN_Click()
Form1.Show
End Sub
OUPTUT:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 50
Programming in visual Basic Subject Code:SAE51
Chevalier T.Thomas College For Woman
Department of Computer Science Page 51
Programming in visual Basic Subject Code:SAE51
Chevalier T.Thomas College For Woman
Department of Computer Science Page 52
Programming in visual Basic Subject Code:SAE51
RESULT:
Thus an MS access table developed for library information system and operation like
insertion,deletion,modification and generating a report are performed in VB.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 53
Programming in visual Basic Subject Code:SAE51
Ex. No : 7 Student Information System
AIM:
To write a menu driven application for creating a database and perform operation like
insertion,deletion,modification and generating report for student information system.
TABLE DESCRIPTION:
S.NO FIELD SIZE DATATYPE DESCRIPTION
NAME
1 Admissionno 10 Number Specifies the admission number
2 Studentname 20 Text Specifies the student name
3 Degree 5 Text Specifies the degree
4 Dept 20 Text Specifies the department
5 Gender 6 Text Specifies the gender
6 Caste 5 Text Specifies the caste
7 Dob Text Specifies the dob
8 Address 30 Text Specifies the address
9 Phone 10 Number Specifies the phone
10 Admdate Date Specifies the adm date
11 Batch 10 Number Specifies the batch
12 Nation 15 Text Specifies the nation
13 Religion 15 Text Specifies the religion
14 Board 15 Text Specifies the board
SOURCE CODE:
CODING FOR FORM1
CODING FOR FORM LOAD
Private Sub Form_Load()
WindowState = 2
End Sub
CODING FOR ADDNEW
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
MsgBox "You can add a new record"
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 54
Programming in visual Basic Subject Code:SAE51
CODING FOR EDIT
Private Sub Command2_Click()
MsgBox "You can update now"
End Sub
CODING FOR SAVE
Private Sub Command3_Click()
Adodc1.Recordset.Update
MsgBox "Your record is saved"
End Sub
CODING FOR DELETE
Private Sub Command4_Click()
Adodc1.Recordset.Delete
MsgBox "Your record is deleted"
End Sub
CODING FOR MOVEFIRST
Private Sub Command5_Click()
Data1.Recordset.MoveFirst
End Sub
CODING FOR MOVEPREVIOUS
Private Sub Command6_Click()
If Adodc1.Recordset.BOF Then
MsgBox "You are in first record"
Else
Adodc1.Recordset.MovePrevious
End If
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 55
Programming in visual Basic Subject Code:SAE51
CODING FOR MOVENEXT
Private Sub Command7_Click()
If Adodc1.Recordset.EOF Then
MsgBox "You are in last record"
Else
Adodc1.Recordset.MoveNext
End If
End Sub
CODING FOR MOVELAST
Private Sub Command8_Click()
Adodc1.Recordset.MoveLast
End Sub
CODING FOR MDIFORM1
GENERAL DECLARATION
Dim GEN, FEES, DEPT As String
Dim REG As Integer
Private Sub MDIForm_Load()
WindowState = 2
End Sub
CODING FOR REPORTS
Private Sub mnudept_Click()
DEPT = InputBox("Enter the department")
DataEnvironment1.rsCommand1.Open ("select * from
studinfo10 where
upper(dept)= '" &UCase(DEPT) & "'")
DataReport1.Show
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 56
Programming in visual Basic Subject Code:SAE51
Private Sub mnureg_Click()
REG = InputBox("Enter the register no of the
student")
DataEnvironment1.rsCommand1.Open ("select * from
studinfo10 where
regno= '" & REG & "'")
DataReport2.Show
End Sub
Private Sub mnugender_Click()
GEN = InputBox("Enter the gender
category(male/female)")
DataEnvironment1.rsCommand1.Open ("select * from
studinfo10 where
upper(gender)='" &UCase(GEN) & "'")
DataReport3.Show
End Sub
Private Sub mnufees_Click()
FEES = InputBox(" Enter the fees details(yes/no)")
DataEnvironment1.rsCommand1.Open ("select * from
studinfo10 where
upper(fees)='" &UCase(FEES) & "'")
DataReport4.Show
End Sub
CODING FOR PROCESS
Private Sub process_Click()
Form1.Show
Form2.Hide
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 57
Programming in visual Basic Subject Code:SAE51
CODING FOR VIEW
Private Sub view_Click()
Form2.Show
Form1.Hide
End Sub
CODING FOR EXIT
Private Sub exit_Click()
Unload Me
End Sub
OUTPUT:
STUDENT INFORMATION SYSTEM
MDI FORM:
FORM 1: STUDENT INFORMATION PROCESSING:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 58
Programming in visual Basic Subject Code:SAE51
FORM 2: STUDENT INFORMATION VIEW:
REPORT 1: DEPT WISE REPORT:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 59
Programming in visual Basic Subject Code:SAE51
REPORT 2: BATCH WISE REPORT:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 60
Programming in visual Basic Subject Code:SAE51
RESULT:
Thus an MS-ACCESS table developed for student information and operation like
insertion,deletion,modification and generating a report are performed in VB.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 61
Programming in visual Basic Subject Code:SAE51
Ex. No : 8 Income Tax Processing System
AIM:
To design a menu driven program for the database application and to perform operation
like insertion,deletion and to generate reports for income tax processing system.
TABLE DESCRIPTION:
S.NO FIELD SIZE DATATYPE DESRIPTION
NAME
1 Employeeno 10 Number Specifies the employee no
2 Employeename 10 Text Specifies the employee name
3 Pan number 15 Number Specifies the pan number
4 Employee type 20 Text Specifies the employee type
5 Designation 10 Text Specifies the designation
6 Gender 15 Text Specifies the gender
7 Residentialaddr 10 Text Specifies the residential address
8 phone 20 Text Specifies the phone
9 officeaddr 20 Text Specifies the office address
TABLE DESCRIPTION:
S.NO FIELD NAME SIZE DATATYPE DESRIPTION
1 Taxid 10 Number Specifies the employee no
2 Date Text Specifies the employee name
3 employeeno 10 Number Specifies the pan number
4 Donation 15 Text Specifies the employee type
5 Annualincome 20 Text Specifies the designation
6 Totalincome 10 Text Specifies the gender
7 Incometaxamt 15 Text Specifies the residential address
8 Incometaxpercentage 10 Text Specifies the phone
9 othertransaction 10 Text Specifies the office address
SOURCE CODE:
CODING FOR FORM1
CODING FOR PROCESS:
Private Sub Command1_Click()
Text12.Text = Val(Text7.Text) + Val(Text8.Text) + Val(Text9.Text) - (Val(Text10.Text) +
Val(Text11.Text))
If (Combo1 = "Male" And Val(Text12.Text) < 60000) Then
Chevalier T.Thomas College For Woman
Department of Computer Science Page 62
Programming in visual Basic Subject Code:SAE51
Text13.Text = "0%"
Text14.Text = 0 * Val(Text12.Text)
ElseIf (Combo1 = "Female" And Val(Text12.Text) < 70000) Then
Text13.Text = "0%"
Text14.Text = 0 * Val(Text12.Text)
ElseIf (Combo1 = "Male" And (Val(Text12.Text) > 60000 And
al(Text12.Text) < 70000)) Then
Text13.Text = "10%"
Text14.Text = 0.1 * Val(Text12.Text)
ElseIf (Combo1 = "Female" And (Val(Text12.Text) > 70000 And
al(Text12.Text) < 80000)) Then
Text13.Text = "10%"
Text14.Text = 0.1 * Val(Text12.Text)
ElseIf (Combo1 = "Male" And Val(Text12.Text) > 70000) Then
Text13.Text = "20%"
Text14.Text = 0.2 * Val(Text12.Text)
ElseIf (Combo1 = "Female" And Val(Text12.Text) > 80000) Then
Text13.Text = "20%"
Text14.Text = 0.2 * Val(Text12.Text)
End If
End Sub
CODING FOR SEARCH:
Private Sub Command10_Click()
s = Val(InputBox("Enter the Employee Number"))
Adodc1.Recordset.MoveFirst
Do Until Adodc1.Recordset.EOF
If Adodc1.Recordset.Fields(0) = s Then
Chevalier T.Thomas College For Woman
Department of Computer Science Page 63
Programming in visual Basic Subject Code:SAE51
MsgBox" Income Tax Details Found "
GoTo s
End If
Adodc1.Recordset.MoveNext
Loop
MsgBox" Income Tax Details Not Found "
s:
End Sub
CODING FOR ADD NEW:
Private Sub Command2_Click()
Adodc1.Recordset.AddNew
CODING FOR EDIT:
Private Sub Command3_Click()
MsgBox "you can edit now"
End Sub
CODING FOR MDI FORM
GENERAL DECLARATION:
Dim itamo As Integer
Dim gend, jobdes As String
CODING FOR BASED ON INCOME TAX AMOUNT REPORT:
Private Sub itr_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
itamo = InputBox("Enter the amount to view the emp details
below/equaltoITamount")
DataEnvironment1.rsCommand1.Open (" Select * from incomtax where
ITamount< = " & Val(itamo))
Chevalier T.Thomas College For Woman
Department of Computer Science Page 64
Programming in visual Basic Subject Code:SAE51
DataReport1.Show
End Sub
CODING FOR JOB DESCRIPTION WISE REPORT:
Private Sub jdw_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
jobdes = UCase(InputBox("Enter the job description"))
DataEnvironment1.rsCommand1.Open (" Select * from incomtax where
upper(desig) ='" &jobdes& "'")
DataReport2.Show
End Sub
CODING FOR GENDER WISE REPORT:
Private Sub gw_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
gend = UCase(InputBox("Enter the Gender"))
DataEnvironment1.rsCommand1.Open (" Select * from incomtax where
upper(gender)='" &gend& "'")
DataReport3.Show
End Sub
CODING FOR INCOME TAX PROCESSING:
Private Sub itp_Click()
Form1.Show
Form2.Hide
End Sub
CODING FOR INCOME TAX VIEWING:
Private Sub itv_Click()
Chevalier T.Thomas College For Woman
Department of Computer Science Page 65
Programming in visual Basic Subject Code:SAE51
Form2.Show
Form1.Hide
End Sub
CODING FOR EXIT:
Private Sub ex_Click()
Unload Me
End Sub
CODING FOR MDI FORM
GENERAL DECLARATION:
Dim itamo As Integer
Dim gend, jobdes As String
CODING FOR BASED ON INCOME TAX AMOUNT REPORT:
Private Sub itr_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
itamo = InputBox("Enter the amount to view the emp details
below/equaltoITamount")
DataEnvironment1.rsCommand1.Open (" Select * from incomtax where
ITamount< = " & Val(itamo))
DataReport1.Show
End Sub
CODING FOR JOB DESCRIPTION WISE REPORT:
Private Sub jdw_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
jobdes = UCase(InputBox("Enter the job description"))
DataEnvironment1.rsCommand1.Open (" Select * from incomtax where
Chevalier T.Thomas College For Woman
Department of Computer Science Page 66
Programming in visual Basic Subject Code:SAE51
upper(desig) ='" &jobdes& "'")
DataReport2.Show
End Sub
CODING FOR GENDER WISE REPORT:
Private Sub gw_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
gend = UCase(InputBox("Enter the Gender"))
DataEnvironment1.rsCommand1.Open (" Select * from incomtax where
upper(gender)='" &gend& "'")
DataReport3.Show
End Sub
CODING FOR INCOME TAX PROCESSING:
Private Sub itp_Click()
Form1.Show
Form2.Hide
End Sub
CODING FOR INCOME TAX VIEWING:
Private Sub itv_Click()
Form2.Show
Form1.Hide
End Sub
CODING FOR EXIT:
Private Sub ex_Click()
Unload Me
End Sub
CODING FOR SAVE:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 67
Programming in visual Basic Subject Code:SAE51
Private Sub Command4_Click()
Adodc1.Recordset.Update
MsgBox "Details saved"
End Sub
CODING FOR DELETE:
Private Sub Command5_Click()
Adodc1.Recordset.Delete
MsgBox "Details deleted"
End Sub
CODING FOR MOVE FIRST:
Private Sub Command6_Click()
Adodc1.Recordset.MoveFirst
End Sub
CODING FOR MOVE PREVIOUS:
Private Sub Command7_Click()
If Adodc1.Recordset.BOF Then
MsgBox "you are in the first entry, there is no previous entry"
Adodc1.Recordset.MoveFirst
Else
Adodc1.Recordset.MovePrevious
End If
End Sub
CODING FOR MOVE NEXT:
Private Sub Command8_Click()
If Adodc1.Recordset.EOF Then
MsgBox "you are in the last entry, there is no next entry"
Adodc1.Recordset.MoveLast
Chevalier T.Thomas College For Woman
Department of Computer Science Page 68
Programming in visual Basic Subject Code:SAE51
Else
Adodc1.Recordset.MoveNext
End If
End Sub
CODING FOR MOVE LAST:
Private Sub Command9_Click()
Adodc1.Recordset.MoveLast
End Sub
CODING FOR FORM LOAD:
Private Sub Form_Load()
Form1.WindowState = 2
End Sub
OUTPUT:
INCOME TAX PROCESSING:
MDI FORM:
FORM 1: INCOME TAX PROCESSING:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 69
Programming in visual Basic Subject Code:SAE51
FORM 2: INCOME TAX VIEW:
REPORT 1 : PERSONAL DETAILS REPORT BY GIVING EMPLOYEE NO:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 70
Programming in visual Basic Subject Code:SAE51
REPORT 2 : TAX DETAILS BY GIVING TAX ID:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 71
Programming in visual Basic Subject Code:SAE51
RESULT:
Thus an Ms-access table developed for income tax processing and operation like
insertion,deletion,modification and generating report are perfomed in VB.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 72
Programming in visual Basic Subject Code:SAE51
Ex. No : 9 Electricity Bill Preparation
AIM:
To design a menu driven program for an database application and to perform operation
like insertion,deletion and to generate reports for electricity bill preparation.
TABLE DESCRIPTION:
S.NO FIELD SIZE DATATYPE DESCRIPTION
NAME
1 Customerno 6 Number Specifies the customer no
2 Customername 10 Text Specifies the customer name
3 Metertype 10 Text Specifies the meter type
4 Address 20 Text Specifies the address
5 Phonenumber 10 Number Specifies the phone number
6 Billnumber 10 Number Specifies the bill number
7 Billdate Date Specifies the bill date
8 Prevread 10 Number Specifies the previous reading
9 Currread 10 Number Specifies the current reading
10 Totalunit 10 Number Specifies the total unit
11 billamt 10 Number Specifies the bill amount
SOURCE CODE:
FORM1 CODING
'GENERAL DECLARATION
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim s As String
Dim i, j, flag As Integer
Private Sub Command1_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Chevalier T.Thomas College For Woman
Department of Computer Science Page 73
Programming in visual Basic Subject Code:SAE51
Text5 = ""
Text6 = ""
Text7 = ""
Option1.Value = True
Text1.SetFocus
flag = 0
End Sub
'CODING FOR DELETE
Private Sub Command2_Click()
Set rs = New ADODB.Recordset
rs.Open ("delete from eb_III where custno=" &Val(Text1)),
cn, adOpenDynamic
MsgBox "record deleted"
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text6 = ""
Text7 = ""
Option1.Value = True
Text1.SetFocus
End Sub
'CODING FOR SAVE
Private Sub Command3_Click()
Set rs = New ADODB.Recordset
If flag = 0 Then
Chevalier T.Thomas College For Woman
Department of Computer Science Page 74
Programming in visual Basic Subject Code:SAE51
rs.Open "Insert into eb_IIIvalues(" & Val(Text1) & ",
'" & (Text2) & "','" & (Text3) & "','" & s & "'," &Val(Text4) & ",
" &Val(Text5) & "," & Val(Text6) & "," & Val(Text7) & ")",
cn, adOpenDynamic
MsgBox "New Record Saved"
Else
rs.Open "Update eb_III Set custno = " &Val(Text1) & ",
cuctname ='" & (Text2) & "',addr = '" & (Text3) & "',
status = '" & s & "',prvread = " & Val(Text4) & ",
crtread = " & Val(Text5) & ",unts = " & Val(Text6) & ",
amt = " & Val(Text7) & "where custno=" & Val(Text1),
cn, adOpenDynamic
MsgBox "Record is Updated"
End If
End Sub
'CODING FOR UPDATE
Private Sub Command4_Click()
MsgBox "now you can update your record"
flag = 1
End Sub
'CODING FOR MOVEFIRST
Private Sub Command5_Click()
If rs.State = 0 Then
Set rs = New ADODB.Recordset
rs.Open ("Select * from eb_III"), cn, adOpenDynamic
End If
If rs.BOF Then
Chevalier T.Thomas College For Woman
Department of Computer Science Page 75
Programming in visual Basic Subject Code:SAE51
MsgBox "Empty Table"
Else
rs.MoveFirst
Display
End If
End Sub
'CODING FOR MOVEPREVIOUS
Private Sub Command6_Click()
If rs.State = 0 Then
Set rs = New ADODB.Recordset
rs.Open ("Select * from eb_III"), cn, adOpenDynamic
End If
If rs.EOF Then
MsgBox "Empty Table"
Else
rs.MovePrevious
If rs.BOF Then
MsgBox "you are in first record"
rs.MoveFirst
End If
Display
End If
End Sub
'CODING FOR MOVENEXT
Private Sub Command7_Click()
If rs.State = 0 Then
Set rs = New ADODB.Recordset
Chevalier T.Thomas College For Woman
Department of Computer Science Page 76
Programming in visual Basic Subject Code:SAE51
rs.Open ("Select * from eb_III"), cn, adOpenDynamic
End If
If rs.BOF Then
MsgBox "Empty Table"
Else
rs.MoveNext
If rs.EOF Then
MsgBox "you are in last record"
rs.MoveLast
End If
Display
End If
End Sub
'CODING FOR MOVELAST
Private Sub Command8_Click()
If rs.State = 0 Then
Set rs = New ADODB.Recordset
rs.Open ("Select * from eb_III"), cn, adOpenDynamic
End If
If rs.EOF Then
MsgBox "Empty Table"
Else
rs.MoveLast
Display
End If
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 77
Programming in visual Basic Subject Code:SAE51
Private Sub Form_Load()
WindowState = 2
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.ConnectionString = "Provider= MSDAORA.1;Password=manager;
User ID=system;Data Source=orcl;Persist Security Info=false"
cn.Open
rs.Open "select * from eb_III", cn, adOpenDynamic
End Sub
'CODING FOR COMERCIAL
Private Sub Option1_Click()
Text6 = Val(Text5.Text) - Val(Text4.Text)
If Option1.Value = True Then
s = "Commercial"
If (Val(Text6) >= 1 And Val(Text6) <= 150) Then
Text7 = Val(Text6.Text) * 1.5
ElseIf (Val(Text6) > 150 And Val(Text6) <= 300) Then
Text7 = Val(Text6.Text) * 2.5
ElseIfVal(Text6) >= 301 Then
Text7 = Val(Text6.Text) * 4
End If
End If
End Sub
'CODING FOR RESIDENTIAL
Private Sub Option2_Click()
Text6 = Val(Text5.Text) - Val(Text4.Text)
If Option2.Value = True Then
Chevalier T.Thomas College For Woman
Department of Computer Science Page 78
Programming in visual Basic Subject Code:SAE51
s = "Residential"
If (Val(Text6)) >= 1 And Val(Text6) <= 150 Then
Text7 = Val(Text6.Text) * 2.5
ElseIf (Val(Text5) >= 151 And Val(Text6) <= 300) Then
Text7 = Val(Text6.Text) * 3.5
Text7 = Val(Text6.Text) * 5
ElseIfVal(Text6) >= 301 Then
Text7 = Val(Text6.Text) * 5
End If
End If
End Sub
Public Sub Display()
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(4)
Text5 = rs(5)
Text6 = rs(6)
Text7 = rs(7)
If rs(3) = "Commercial" Then
Option1.Value = True
ElseIfrs(3) = "Residential" Then
Option2.Value = True
End If
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 79
Programming in visual Basic Subject Code:SAE51
Public Sub Save()
rs(0) = Val(Text1)
rs(1) = Text2
rs(2) = Text3
rs(4) = Val(Text4)
rs(5) = Val(Text5)
rs(6) = Val(Text6)
rs(7) = Val(Text7)
If Option1.Value = True Then
rs(3) = "Commercial"
ElseIf Option2.Value = True Then
rs(3) = "Residential"
End If
End Sub
MDI FORM CODING
Private Sub MDIForm_Load()
WindowState = 2
End Sub
Private Sub mnex_Click()
Unload Me
End Sub
Private Sub mnpro_Click()
Form1.Show
End Sub
Private Sub mnstus_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
Chevalier T.Thomas College For Woman
Department of Computer Science Page 80
Programming in visual Basic Subject Code:SAE51
Status = InputBox("Enter the Status Commercial /
Residential to View the Amounts in Sorted Order")
DataEnvironment1.rsCommand1.Open (" select * from eb_III where
upper(status)='" &UCase(Status) & "' order by amt")
DataReport1.Show
End Sub
Private Sub mnvw_Click()
Form2.Show
End Sub
Private Sub s_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
custno = InputBox("Enter the cust no to view his Electricity Bill")
DataEnvironment1.rsCommand1.Open ("select * from eb_III where
CUSTNO=" &custno)
DataReport2.Show
End Sub
OUTPUT:
ELECTRICITY BILL:
MDI FORM:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 81
Programming in visual Basic Subject Code:SAE51
CUSTOMER DETAILS PROCESS FORM:
ADD & SAVE DETAILS:
VIEW DETAILS:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 82
Programming in visual Basic Subject Code:SAE51
REPORT:
CUSTOMER REPORT DETAILS:
DISPLAYING RECORD FOR A PARTICULAR CUSTOMER NUMBER:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 83
Programming in visual Basic Subject Code:SAE51
DISPLAYING ALL RECORDS:
RESULT:
Thus an MS-Access table developed for electricity bill preparation and operation like
insertion,deletion,modification and generating reports are performed in VB.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 84
Programming in visual Basic Subject Code:SAE51
Ex. No : 10 Telephone Directory Maintence
AIM:
To design a menu driven program for an database application and to perform
operation like insertion,deletion and to generate reports for telephone directory maintence.
TABLE DESCRIPTION:
S.NO FIELD SIZE DATATYPE DESCRIPTION
NAME
1 Customerid 10 Number Specifies the customer id
2 Customername 10 Text Specifies the customer name
3 Phonenumber 10 Number Specifies the phone number
4 Addphno 10 Number Specifies the additional phone number
5 Address 20 Text Specifies the address
6 City 10 Text Specifies the city
7 pincode 15 Number Specifies the pincode
SOURCE CODE:
Telephone Directory
CODING FOR MDIFORM
Dim are, nam, alpha As String
Private Sub a_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
End If
are = InputBox("Enter the areaname:")
DataEnvironment1.rsCommand1.Open ("select * from
teledi where
Area='" & are & "' ")
DataReport1.Show
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 85
Programming in visual Basic Subject Code:SAE51
Private Sub al_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
End If
alpha = InputBox("Enter the First Letter of the
Names")
DataEnvironment1.rsCommand1.Open (" select *
from teledi where
Name like '" & alpha & "%'")
DataReport1.Show
End Sub
Private Sub d_Click()
Form1.Show
Form2.Hide
End Sub
Private Sub e_Click()
Unload Me
CODING FOR MDIFORM
Dim are, nam, alpha As String
Private Sub a_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
End If
Chevalier T.Thomas College For Woman
Department of Computer Science Page 86
Programming in visual Basic Subject Code:SAE51
are = InputBox("Enter the areaname:")
DataEnvironment1.rsCommand1.Open ("select * from
teledi where
Area='" & are & "' ")
DataReport1.Show
End Sub
Private Sub al_Click()
If DataEnvironment1.rsCommand1.State = 1 Then
DataEnvironment1.rsCommand1.Close
End If
alpha = InputBox("Enter the First Letter of the
Names")
DataEnvironment1.rsCommand1.Open (" select *
from teledi where
Name like '" & alpha & "%'")
DataReport1.Show
End Sub
Private Sub d_Click()
Form1.Show
Form2.Hide
End Sub
Private Sub e_Click()
Unload Me
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 87
Programming in visual Basic Subject Code:SAE51
CODING FOR FORM1
CODING FOR ADDNEW
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
MsgBox "You can add record now"
End Sub
CODING FOR EDIT
Private Sub Command2_Click()
MsgBox "You can update know"
End Sub
CODING FOR SAVE
Private Sub Command3_Click()
Adodc1.Recordset.Update
MsgBox "Your record is saved"
End Sub
CODING FOR DELETE
Private Sub Command4_click()
Adodc1.Recordset.Delete
End Sub
CODING FOR SEARCH
Private Sub Command5_Click()
Dim a As Double
Chevalier T.Thomas College For Woman
Department of Computer Science Page 88
Programming in visual Basic Subject Code:SAE51
a = Val(InputBox("Enter phone no"))
Adodc1.Recordset.MoveFirst
Do Until Adodc1.Recordset.EOF
If Adodc1.Recordset.Fields(5) = a Then
MsgBox "Record found"
GoTo a
End If
Adodc1.Recordset.MoveNext
Loop
MsgBox "Record not found"
a:
End Sub
CODING FOR MOVE FIRST
Private Sub Command6_Click()
Adodc1.Recordset.MoveFirst
End Sub
CODING FOR MOVE PREVIOUS
Private Sub Command7_Click()
If Adodc1.Recordset.BOF Then
MsgBox "You are at first record"
Else
Adodc1.Recordset.MovePrevious
End If
End Sub
Chevalier T.Thomas College For Woman
Department of Computer Science Page 89
Programming in visual Basic Subject Code:SAE51
CODING FOR MOVE NEXT
Private Sub Command8_Click()
If Adodc1.Recordset.EOF Then
MsgBox "You are at last record'"
Else
Adodc1.Recordset.MoveNext
End If
End Sub
CODING FOR MOVE LAST
Private Sub Command9_Click()
Adodc1.Recordset.MoveLast
End Sub
OUTPUT:
TELEPHONE DIRECTORY MAINTANENCE
MDI FORM:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 90
Programming in visual Basic Subject Code:SAE51
FORM 1: PROCESS:
FORM 2: VIEW:
DATA REPORT:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 91
Programming in visual Basic Subject Code:SAE51
DATA REPORT 1 :
AREA WISE REPORT:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 92
Programming in visual Basic Subject Code:SAE51
DATA REPORT 2:
NAME WISE REPORT FOR PERSONS STARTING WITH LETTER ‘H’:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 93
Programming in visual Basic Subject Code:SAE51
REPORT FOR PERSONS STARTING WITH LETTER ‘H’:
DATA REPORT 3:
PHONE NO WISE REPORT:
REPORT FOR PHONE NO: 04426591229:
Chevalier T.Thomas College For Woman
Department of Computer Science Page 94
Programming in visual Basic Subject Code:SAE51
RESULT:
Thus an MS-Access table developed for telephone directory maintanence and operation like
insertion,deletion,modification and generating reports are performed in VB.
Chevalier T.Thomas College For Woman
Department of Computer Science Page 95