Time calculation add/delete in data grid getting problem
|
Contributor
|
|
| 9Aug2010,10:20 | #1 |
|
Time calculation add/delete in data grid getting problem while running
|
|
Newbie Member
|
|
| 9Aug2010,13:37 | #2 |
|
Why do you still use VB6? Why there's need to learn VB6 when you can take the advantage of learning the new VB.NET?
You know, there was a long battle about the migration to .NET. I don't know why some of you still used the supposed long-lost language.
viv345
like this
|
|
Go4Expert Founder
|
![]() |
| 9Aug2010,15:26 | #3 |
|
You may need to because no VB developer wants to migrate to .NEt unless he is compelled to.
viv345
like this
|
|
Pro contributor
|
![]() |
| 10Aug2010,03:56 | #4 |
|
send your project in a zip file plus the database you use
in order to check it.
viv345
like this
|
|
Contributor
|
|
| 12Aug2010,17:10 | #5 |
|
1. Not showing in Data grid
2. Not Saving in DB20 |
|
Contributor
|
|
| 12Aug2010,17:36 | #6 |
|
And if I like to calculate the Grand Total of all Totals in a grid. HOW?
|
|
Pro contributor
|
![]() |
| 13Aug2010,04:43 | #7 |
|
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 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
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
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
and your project with the changes is here |
|
Contributor
|
|
| 14Aug2010,19:04 | #8 |
|
Thanks!
I tried the same but giving problem |
|
Contributor
|
|
| 14Aug2010,19:37 | #9 |
|
Sir
And code given for calculating column what i do if i had to calculate Rows |



