0% found this document useful (0 votes)
26 views29 pages

VB Lab PDF

Uploaded by

Narenkumar. N
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)
26 views29 pages

VB Lab PDF

Uploaded by

Narenkumar. N
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
You are on page 1/ 29

1.

PAY ROLL PROCESSING

Aim:
To implement a Visual Basic program to calculate employee total earnings.

Procedure :
1. Start
2. Design the form with text boxes, command buttons and label controls. Display appropriate
messages in label boxes
3. Write the script in the click event on the process command button.
4. Stop

Property Settings:
Control Name Property Value
Command button command1 Name cmdclc
Command Button Command2 Name cmdclose
Command button command1 Caption Calculate
Command Button Command2 Caption Close
Textbox Text1 name txtbp
Textbox Text2 name txthra
Textbox Text3 name txtda
Textbox Text4 name txtcon
Textbox Text5 name txtlic
Textbox Text6 name txtinc
Textbox Text7 name txtloa
Textbox Text8 name txtoth
Textbox Text9 name txtgs
Textbox Text10 name txtns
Textbox Text1 Text
Textbox Text2 Text
Textbox Text3 Text
Textbox Text4 Text
Textbox Text5 Text
Textbox Text6 Text
Textbox Text7 Text
Textbox Text8 Text
Textbox Text9 Text
Textbox Text10 Text
Label Label1 Caption Pay Roll Processing
Label Label2 Caption Basic Pay
Label Label3 Caption HRA(15%)
Label Label4 Caption DA(40%)
Label Label5 Caption Conveyance(10%)
Label Label6 Caption LIC
Label Label7 Caption Income Tax
Label Label8 Caption Loans
Label Label9 Caption Others
Label Label10 Caption Gross Salary
Label Label11 Caption Net Salary
Form Design

SOURCE CODE:
Private Sub cmdclc_Click()
If txtbp.Text = "" Then
MsgBox "You should Enter Basic Pay"
txtbp.SetFocus
Exit Sub
End If
If txtlic = "" Then
txtlic = 0
End If
If txtinc = "" Then
txtinc = 0
End If
If txtloa = "" Then
txtloa = 0
End If
If txtoth = "" Then
txtoth = 0
End If
txthra = txtbp * 15 / 100
txtda = txtbp * 40 / 100
txtcon = txtbp * 10 / 100
txtgs = Val(txtbp) + Val(txthra) + Val(txtda) + Val(txtcon)
txtns = Val(txtgs) - Val(txtlic) - Val(txtinc) - Val(txtloa) - Val(txtoth)
End Sub
Private Sub cmdend_Click()
End
End Sub

RESULT
Thus the Visual Basic program to calculate the total earning of the employee has been executed
successfully.
2. MARK SHEET PROCESSING

Aim:
To implement a Visual Basic program to prepare student marksheet.

Procedure :
1. Start
2. Design the form with text boxes , command buttons and label controls. Display appropriate
messages in label boxes
3. Write the script in the click event on the calculate command button.
4. Stop

Property Settings:
Control Name Property Value
Command button command1 Name cmdclc
Command button command1 Caption Calculate
Textbox Text1 name txtsub1
Textbox Text2 name txtsub2
Textbox Text3 name txtsub3
Textbox Text4 name txtsub4
Textbox Text5 name txtsub5
Textbox Text6 name txttot
Textbox Text7 name txtper
Textbox Text8 name txtgra
Label Label1 Caption Marksheet
Label Label2 Caption Tamil
Label Label3 Caption English
Label Label4 Caption Maths
Label Label5 Caption Science
Label Label6 Caption Social
Label Label7 Caption Total
Label Label8 Caption Percentage
Label Label9 Caption Grade
Label Label10 Caption Remark
Label Label11 Caption
Label Label11 Name lblrem
Form Design

SOURCE CODE:

Private Sub cmdclc_Click()


Dim s1, s2, s3, s4, s5 As Integer
Dim tot, per As Double
Dim grade As String
Dim s As String
s1 = Val(txtsub1.Text)
s2 = Val(txtsub2.Text)
s3 = Val(txtsub3.Text)
s4 = Val(txtsub4.Text)
s5 = Val(txtsub5.Text)
tot = s1 + s2 + s3 + s4 + s5
per = tot / 5
txttot.Text = tot
txtper.Text = per
If s1 >= 35 And s2 >= 35 And s3 >= 35 And s4 >= 35 And s5 >= 35 Then
Select Case per
Case Is > 90
grade = "E"
Case Is > 60
grade = "A"
Case Is > 50
grade = "B"
Case Is > 35
grade = "C"
End Select
txtgra.Text = grade
s = txtgra.Text
Select Case s
Case "E"
lblrem.Caption = "Excellent"
Case "A"
lblrem.Caption = "Very Good"
Case "B"
lblrem.Caption = "Good"
Case "C"
lblrem.Caption = "Average"
End Select
Else
txtgra.Text = "F"
lblrem.Caption = "Fail"
End If
End Sub
Private Sub Form_Load()
txtgra.Enabled = False
End Sub

OUTPUT:

RESULT

Thus the Visual Basic program to create the student mark sheet has been executed successfully
3. SAVING BANK ACCOUNT FOR BANKING

Aim:
To implement a Visual Basic program to prepare saving bank account for banking.

Procedure :
1. Start
2. Design the form with text boxes , combo box and label controls. Display appropriate
messages in label boxes
3. Write the script in the click event on the calculate command button.
4. Stop

Property Settings:

Control Name Property Value


Label Lable1 Caption Banking System
Label Label2 Caption Accno
Label Label3 Caption Name
Label Label4 Caption Date
Label Label5 Caption Enter the Amount
Label Label6 Caption Select the type of Tansaction
Label Label7 Caption Withdrawl Amount
Label Label7 Name lblwith
Label Label8 Caption Deposit Amount
Label Label8 Name lbldepo
Label Label9 Caption Previous Balance
Label Label10 Caption Current Balance
Label Label10 Name lblcur
Combo Combo1 Name cmp1
Text Text1 Text
Text Text2 Text
Text Text3 Text
Text Text4 Text
Text Text5 Text
Text Text6 Text
Text Text7 Text
Text Text8 Text
Text Text1 Name txtaco
Text Text2 Name txtname
Text Text3 Name txtdate
Text Text4 Name txtamt
Text Text5 Name txtwith
Text Text6 Name txtdepo
Text Text7 Name txtpre
Text Text Name txtcur
Source Code:
Private Sub cmp1_Click()
If cmp1.Text = "Deposit" Then
txtpre.Text = Val(txtcur.Text)
txtdepo.Text = Val(txtamt.Text)
txtwith.Visible = False
lblwith.Visible = False
txtdepo.Visible = True
lbldepo.Visible = True
txtcur.Text = Val(txtpre.Text) + Val(txtdepo.Text)
ElseIf cmp1.Text = "Withdraw" Then
txtpre.Text = Val(txtcur.Text)
If txtpre.Text = 0 Then
MsgBox "no balance"
txtcur.Text = 0
txtamt.Text = ""
txtamt.SetFocus
lblwith.Visible = False
txtwith.Visible = False
Else
txtwith.Text = Val(txtamt.Text)
If Val(txtwith.Text) > Val(txtcur.Text) Then
MsgBox "Insufficient Balance"
txtwith.Visible = False
txtcur.Visible = False
lblcur.Visible = False
txtamt.Text = ""
txtamt.SetFocus
lblwith.Visible = False
txtwith.Visible = False
End If
txtdepo.Visible = False
lbldepo.Visible = False
txtcur.Text = Val(txtpre.Text) - Val(txtwith.Text)
End If
End If
End Sub

Private Sub Form_Load()


cmp1.AddItem "Withdraw"
cmp1.AddItem "Deposit"
txtpre.Text = 20000
txtcur.Text = txtpre.Text
txtdate.Text = Now
End Sub
Form Design
4. INVENTORY SYSTEM

Property Settings:

Control Name Property Value


Label Label1 Caption Inventory System
Label Label2 Caption Item Name
Label Label3 Caption Item Price
Label Label4 Caption Quantity
Label Label5 Caption Total Amount
Label Label6 Caption Existing Stock
Label Label7 Caption Existing Stock
Command Command1 Name cmdclc
Command Command2 Caption Calculate
Text text1 Text
Text text1 Name txtiname
Text text2 Text
Text text2 Name txtiprice
Text text3 Text
Text text3 Name txtiqty
Text text4 Text
Text text5 Name txttotamt
Text text5 Text
Text text5 Name txtstock
Text text6 Text
Text text6 Name txtcurstock
Combo Combo1
Private Sub cmdclc_Click()
txttotamt = Val(txtiprice.Text) * Val(txtiqty.Text)
Select Case (Combo1.ListIndex)
Case 0: sug_stock = sug_stock - Val(txtiqty.Text)
txtcurstock.Text = sug_stock
Case 1: rice_stock = rice_stock - Val(txtiqty.Text)
txtcurstock.Text = rice_stock
End Select
End Sub
Private Sub Combo1_Click()
txtiprice.Text = ""
txtiqty.Text = ""
txttotamt.Text = ""
txtcurstock.Text = ""
Select Case (Combo1.ListIndex)
Case 0: txtiname.Text = "Sugar"
txtstock.Text = sug_stock

Case 1: txtiname.Text = "Rice"


txtstock.Text = rice_stock

End Select
End Sub

Private Sub Form_Load()


sug_stock = 40
rice_stock = 20
Combo1.AddItem "1"
Combo1.AddItem "2"
End Sub
5. INVOICE SYSTEM

Property Settings:

Control Name Property Value


Label Label1 Caption Invoice Systems
Label Label2 Caption Net Amount
Label Label3 Caption Item Name
Label Label4 Caption Item price
Label Label5 Caption Quantity
Text Text1 Text
Text Text1 Name txttot
Text Text2 Text
Text Text2 Name txtite
Text Text3 Text
Text Text3 Name txtpri
Text Text4 Text
Text Text4 Name txtqty
Command Command1 Caption Add
Command Command1 Name cmdadd
MSFlexGrid MSFlexGrid1

To add MSFlexGrid
Project → Components → Microsoft FlexGrid control

Form Design
Private Sub cmdadd_Click()
If Trim(txtite.Text) = "" Then
MsgBox "Item Name is missing"
txtite.SetFocus
GoTo endp
ElseIf Trim(txtpri.Text) = "" Then
MsgBox "iTEM PRICE IS MISSING"
txtpri.SetFocus
GoTo endp
ElseIf Trim(txtqty.Text) = "" Then
MsgBox "Item Qty missing"
txtqty.SetFocus
GoTo endp
ElseIf Val(txtqty.Text) <= 0 Then
MsgBox "item qty must be positive"
txtqty.SetFocus
GoTo endp
Else
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = Trim(txtite.Text)
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = Trim(txtpri.Text)
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = Trim(txtqty.Text)
MSFlexGrid1.Col = 3
item_total = Val(txtpri.Text) * Val(txtqty.Text)
MSFlexGrid1.Text = item_total
txttot.Text = item_total + Val(txttot.Text)
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
txtite.Text = ""
txtpri.Text = ""
txtqty.Text = ""
End If
endp:
End Sub

Private Sub Form_Load()


MSFlexGrid1.TextMatrix(0, 0) = "Item Name"
MSFlexGrid1.TextMatrix(0, 1) = "Item Price"
MSFlexGrid1.TextMatrix(0, 2) = "Quantity"
MSFlexGrid1.TextMatrix(0, 3) = "Total"
End Sub
ELECTRICITY BILL
Aim:
To implement a Visual Basic program to calculate electricity bill.
Procedure :
1. Start
2. Design the form with text boxes and command buttons. Display appropriate messages in label
boxes
3. Write the script in the click event on the Calculate Bill command button.
4. Stop
Property Settings:
Control Name Property Value
Command button command1 Name cmdclc
Textbox Text1 name txtnum
Textbox Text2 name txtname
Textbox Text3 name txtunit
Textbox Text4 name txtamt
Label Label1 Caption Consumer Number
Label Label2 Caption Consumer Name
Label Label3 Caption Units Consumed
Label Label4 Caption Total Amount

Form Design

SOURCE CODE
Private Sub cmdclc_Click()
Dim sum As Single
Dim unit As Integer
If txtnum.Text = "" Or txtname.Text = "" Then
MsgBox "Enter Consumer Number and Name"
End If
unit = Round(Val(txtunit.Text))
If unit > 300 Then
sum = (unit - 300) * 1.25
unit = 300
End If
If unit > 200 Then
sum = sum + (unit - 200) * 1
unit = 200
End If
If unit > 100 Then
sum = sum + (unit - 100) * 0.85
unit = 100
End If
sum = sum + unit * 0.5
txtamt.Text = sum
End Sub
OUTPUT

RESULT:
Thus the Visual Basic program to create the electricity bill has been executed successfully.
TAX AMOUNT CALCULATION
Aim:
To implement a Visual Basic program to calculate tax amount.
Procedure :
1. Start
2. Design the form with text boxes and command buttons. Display appropriate messages in label
boxes
3. Write the script in the click event on the Calculate and close command button.
4. Stop
Property Settings:
Control Name Property Value
Command button command1 Name cmdclculate
Command button command Name cmdclose
Textbox Text1 name txtmarpri
Textbox Text2 name txttaxrate
Textbox Text3 name txttaxamt
Textbox Text4 name txtnetpri
Label Label1 Caption Marked Price
Label Label2 Caption Tax Rate
Label Label3 Caption Tax Amount
Label Label4 Captio Netprice
Form Design

SOURCE CODE
Private Sub cmdcalculate_Click()
Dim markedprice As Currency
Dim taxrate As Double
Dim taxamount As Currency
Dim netprice As Currency
markedprice = CCur(txtmarpri.Text)
taxrate = txttaxrate.Text / 100
taxamount = markedprice * taxrate
netprice = markedprice + taxamount
txtmarpri.Text = FormatCurrency(markedprice)
txttaxamt.Text = FormatCurrency(taxamount)
txtnetpri.Text = FormatCurrency(netprice)
End Sub
Private Sub cmdclose_Click()
End
End Sub
Output

RESULT
Thus the Visual Basic program to calculate tax amount has been executed successfully.
Ex. No: 8

Aim:

To implement a Visual Basic program to maintain the student database using DATA
CONTROL.

Procedure :

1. Start

2. Design the form with text boxes, Label boxes, Data Control and command buttons. Display
appropriate messages in label boxes.

3. Write the script in the click event on the Calculate and close command button.

4. Stop

Procedure to Create Table in MS Access :

AddIns->Visual Data Manager

File->New->Microsoft Access ->version 7.0

Database Name: Student

Right Click on Database Window and Create New Table

Enter the Table name

Add the field names, type of the fields, etc and click the build table command button.

Property Settings:

Control Name Property Value

Command button command1 Name cmdadd

Command button command2 Name cmdsave

Command button command3 Name cmddelete

Command button command4 Name cmdmodify

Command button command5 Name cmdexit

Textbox Text1 name txtregno

Textbox Text2 name txtname


Textbox Text3 name txtdob

Textbox Text4 name txtsex

Textbox Text5 name txtrel

Textbox Text6 name txtnat

Textbox Text7 name txtfname

Textbox Text8 name txtmname

Textbox Text9 name txtaddr

Textbox Text10 name txtcon

Textbox Text11 name txtcourse

Textbox Text12 name txtyear

Label Label1 Caption Regno

Label Label2 Caption Name

Label Label3 Caption DOB

Label Label4 Caption Sex

Label Label5 Caption Religion

Label Label6 Caption Nationality

Label Label1 Caption Father’s Name

Label Label1 Caption Mother’s Name

Label Label1 Caption Address

Label Label1 Caption Contact No

Label Label1 Caption Course

Label Label1 Caption Year

Data Control Data1 DataBaseName C:\Documents and


Settings\student\Desktop\STUDENT.MDB

Record Source studenttable

Form Design
Source Code:

Private Sub cmdadd_Click()

MsgBox "enter new records", vbInformation, "student"

Data1.Recordset.AddNew

End Sub

Private Sub cmddelete_Click()

Data1.Recordset.Delete

MsgBox "one record deleted", vbApplicationModal, "Student"

a = MsgBox("Are u sure you want to delete the record?", vbYesNo + vbCritical)

End Sub

Private Sub cmdexit_Click()

End
End Sub

Private Sub cmdmodify_Click()

Data1.Recordset.Edit

MsgBox "one record updated", vbInformation, "student"

End Sub

Private Sub cmdsave_Click()

Data1.Recordset.Update

MsgBox "one record updated", vbInformation, "student"

End Sub

OUTPUT:
Result:

The Student information system is maintianed using data control program has been executed
sucessfully.
Ex. No: 9

Aim:

To implement a Visual Basic program to maintain the student database using


DATA CONTROL.

Procedure :
1. Start

2. Design the form with text boxes, Label boxes, Data Control and command buttons. Display
appropriate messages in label boxes.

3. Write the script in the click event on the Calculate and close command button.

4. Stop

Procedure to Create Table in MS Access :

AddIns->Visual Data Manager

File->New->Microsoft Access ->version 7.0

Database Name: Student

Right Click on Database Window and Create New Table

Enter the Table name

Add the field names, type of the fields, etc and click the build table command button.

Property Settings:

Control Name Property Value

Command button command1 Name cmdadd

Command button command2 Name cmdsave

Command button command3 Name cmddelete

Command button command4 Name cmdmodify

Command button command5 Name cmdexit

Textbox Text1 name txtregno

Textbox Text2 name txtname


Textbox Text3 name txtdob

Textbox Text4 name txtsex

Textbox Text5 name txtrel

Textbox Text6 name txtnat

Textbox Text7 name txtfname

Textbox Text8 name txtmname

Textbox Text9 name txtaddr

Textbox Text10 name txtcon

Textbox Text11 name txtcourse

Textbox Text12 name txtyear

Label Label1 Caption Regno

Label Label2 Caption Name

Label Label3 Caption DOB

Label Label4 Caption Sex

Label Label5 Caption Religion

Label Label6 Caption Nationality

Label Label1 Caption Father’s Name

Label Label1 Caption Mother’s Name

Label Label1 Caption Address

Label Label1 Caption Contact No

Label Label1 Caption Course

Label Label1 Caption Year

Data Control Data1 DataBaseName C:\Documents and


Settings\student\Desktop\STUDENT.MDB

Record Source studenttable

Form Design
Source Code:

Private Sub cmdadd_Click()

MsgBox "enter new records", vbInformation, "student"

Data1.Recordset.AddNew

End Sub

Private Sub cmddelete_Click()

Data1.Recordset.Delete

MsgBox "one record deleted", vbApplicationModal, "Student"

a = MsgBox("Are u sure you want to delete the record?", vbYesNo + vbCritical)

End Sub

Private Sub cmdexit_Click()

End
End Sub

Private Sub cmdmodify_Click()

Data1.Recordset.Edit

MsgBox "one record updated", vbInformation, "student"

End Sub

Private Sub cmdsave_Click()

Data1.Recordset.Update

MsgBox "one record updated", vbInformation, "student"

End Sub

OUTPUT:
Result:

The Student information system is maintianed using data control program has been executed
sucessfully.

You might also like