VB Lab PDF
VB Lab PDF
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:
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:
Property Settings:
End Select
End Sub
Property Settings:
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
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
Add the field names, type of the fields, etc and click the build table command button.
Property Settings:
Form Design
Source Code:
Data1.Recordset.AddNew
End Sub
Data1.Recordset.Delete
End Sub
End
End Sub
Data1.Recordset.Edit
End Sub
Data1.Recordset.Update
End Sub
OUTPUT:
Result:
The Student information system is maintianed using data control program has been executed
sucessfully.
Ex. No: 9
Aim:
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
Add the field names, type of the fields, etc and click the build table command button.
Property Settings:
Form Design
Source Code:
Data1.Recordset.AddNew
End Sub
Data1.Recordset.Delete
End Sub
End
End Sub
Data1.Recordset.Edit
End Sub
Data1.Recordset.Update
End Sub
OUTPUT:
Result:
The Student information system is maintianed using data control program has been executed
sucessfully.