first of all why you send different code from the first post?

now about your code
there are many things you do not know.

1) hours1 = CInt(Text2.Text)
this will get you a runtime error 13 type mismatch
if text2 is empty or if user entered a string instead of a number.
if you use val(text2.text) instead you will have 0 as result

2)If Text4.Text = 1 Then
Text56.Text = 1 * 10#
End If


text4.text is a string and like this you must handle it
the correct is
Code:
If val(Text4.Text) = 1 Then
   Text56.Text = cstr(1 * 10#)
   End If
val(string)-->give us its numerical value
Cstr(number)-->give us a string representing our number


3) your form is misleading the user
in the total hours column you have the hours and below the minutes
but the labeling is not good.Try to make it better

4)in a previous post of yours i had answered how to add and delete from datagrid
but you did not use that in this project

Code:
Private Sub cmddelete_Click() 'delete button
If Adodc1.Recordset.RecordCount <= 0 Then
MsgBox "no record found"
Exit Sub
End If
Dim answer As Integer
answer = MsgBox("do you want to delete current record?", vbYesNoCancel, "DELETE")
If answer = vbYes And Adodc1.Recordset.RecordCount > 0 Then Adodc1.Recordset.Delete
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
End Sub
the above code deletes the currently selected row of a datagrid and the record from database

Code:
Private Sub cmdadd_Click() 'Add New Record
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("field1") = Text1.Text
Adodc1.Recordset.Fields("field2") = Text2.Text
Adodc1.Recordset.Fields("field3") = Text3.Text
Adodc1.Recordset.Fields("field4") = Text4.Text
Adodc1.Recordset.Fields("field5") = Text5.Text
Adodc1.Recordset.Fields("field6") = Text6.Text
Adodc1.Recordset.Fields("field7") = Text7.Text
Adodc1.Recordset.Fields("field8") = Text8.Text
Adodc1.Recordset.Fields("field9") = Text9.Text
Adodc1.Recordset.Fields("field10") = Text10.Text
Adodc1.Recordset.Update
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
End Sub
the above code inserts data in datagrid and in database

Code:
Private Sub cmdTotalGrid_Click()
Dim i, a As Integer
a = 0
Adodc1.Recordset.MoveFirst 'Move the record position to the first
'Iteration for row by row
For i = 1 To Adodc1.Recordset.RecordCount
    'Calculate the result
    a = a + Val(DataGrid1.Columns(9).Text)
    Adodc1.Recordset.MoveNext
Next
MsgBox "result=" + CStr(a)
End Sub
the above code adds all the data stored in field10 column

and your project with the changes is here
Attached Files
File Type: rar timecalc.rar (16.8 KB, 7 views)
shabbir, viv345 likes this