AIM:
To calculate the payroll of an employee using Data control.
PROCEDURE:
Step 1: Create a standard exe project.
Step 2: Click adding options from menu bar.
Step 3: Click visual managerà click fileà newà Microsoft access version 7.0Mdb.
Step 4: Enter the database and save it in desired location.
Step 5: Right click the prosperities in database window and click new table.
Step 6: Enter table name and add the fields. Now click the build the table. Then go to the form and place the necessary labels text boxes and command buttons.
Step 7: Place one data control in the form.
Step 8: Write the corresponding code for all the button and run the program.
SOURCE CODE:
Dim db As Database
Dim rs As Recordset
Function clr()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
End Function
Function store()
rs.Fields(0) = Text1.Text
rs.Fields(1) = Text2.Text
rs.Fields(2) = Text3.Text
rs.Fields(3) = Text4.Text
rs.Fields(4) = Text5.Text
rs.Fields(5) = Text6.Text
rs.Fields(6) = Text7.Text
rs.Fields(7) = Text8.Text
rs.Fields(8) = Text9.Text
End Function
Function retrive()
Text1.Text = rs.Fields(0)
Text2.Text = rs.Fields(1)
Text3.Text = rs.Fields(2)
Text4.Text = rs.Fields(3)
Text5.Text = rs.Fields(4)
Text6.Text = rs.Fields(5)
Text7.Text = rs.Fields(6)
Text8.Text = rs.Fields(7)
Text9.Text = rs.Fields(8)
End Function
Private Sub Cmdadd_Click()
rs.AddNew
Call clr
Text1.SetFocus
End Sub
Private Sub Cmdedit_Click()
rs.Edit
End Sub
Private Sub Cmdsave_Click()
Call store
rs.Update
Call clr
End Sub
Private Sub Cmddelete_Click()
rs.Delete
Call clr
Text1.SetFocus
End Sub
Private Sub Cmdclr_Click()
Call clr
End Sub
Private Sub Cmdexit_Click()
End
End Sub
Private Sub Cmdmovefirst_Click()
If rs.EOF Then
MsgBox "THERE IS NO RECORD"
Else
rs.MoveFirst
End If
callretrive
End Sub
Private Sub Cmdmovelast_Click()
If rs.EOF Then
MsgBox "THERE IS NO RECORD"
Else
rs.MoveLast
End If
callretrive
End Sub
Private Sub Cmdmovenext_Click()
rs.MoveNext
If rs.EOF Then
rs.MoveLast
End If
Call retrive
End Sub
Private Sub Cmdmoveprevious_Click()
rs.MovePrevious
If rs.BOF Then
rs.MoveFirst
End If
Call retrive
End Sub
Private Sub Form_Load()
Set db = OpenDatabase("F:\ VISUAL_BASICS\payroll_data.mdb")
Set rs = db.OpenRecordset("employee")
End Sub
Private Sub Text3_Change()
Text10.Text = Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text)
Text11.Text = Val(Text10.Text) - Val(Text7.Text) - Val(Text8.Text) - Val(Text9.Text)
End Sub
Private Sub Text4_Change()
Text10.Text = Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text)
Text11.Text = Val(Text10.Text) - Val(Text7.Text) - Val(Text8.Text) - Val(Text9.Text)
End Sub
Private Sub Text5_Change()
Text10.Text = Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text)
Text11.Text = Val(Text10.Text) - Val(Text7.Text) - Val(Text8.Text) - Val(Text9.Text)
End Sub
Private Sub Text6_Change()
Text10.Text = Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text)
Text11.Text = Val(Text10.Text) - Val(Text7.Text) - Val(Text8.Text) - Val(Text9.Text)
End Sub
Private Sub Text7_Change()
Text10.Text = Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text)
Text11.Text = Val(Text10.Text) - Val(Text7.Text) - Val(Text8.Text) - Val(Text9.Text)
End Sub
Private Sub Text8_Change()
Text10.Text = Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text)
Text11.Text = Val(Text10.Text) - Val(Text7.Text) - Val(Text8.Text) - Val(Text9.Text)
End Sub
Private Sub Text9_Change()
Text10.Text = Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text)
Text11.Text = Val(Text10.Text) - Val(Text7.Text) - Val(Text8.Text) - Val(Text9.Text)
End Sub
SCREEN LAYOUT:

OUTPUT:

0 comments:
Post a Comment