Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   Time calculation add/delete in data grid getting problem (http://www.go4expert.com/forums/time-calculation-add-delete-data-grid-t22974/)

viv345 9Aug2010 10:20

Time calculation add/delete in data grid getting problem
 
2 Attachment(s)
Time calculation add/delete in data grid getting problem while running

enigmaCore 9Aug2010 13:37

Re: Time calculation add/delete in data grid getting problem
 
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.

shabbir 9Aug2010 15:26

Re: Time calculation add/delete in data grid getting problem
 
Quote:

Originally Posted by enigmaCore (Post 71350)
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.

You may need to because no VB developer wants to migrate to .NEt unless he is compelled to.

virxen 10Aug2010 03:56

Re: Time calculation add/delete in data grid getting problem
 
send your project in a zip file plus the database you use
in order to check it.

viv345 12Aug2010 17:10

Re: Time calculation add/delete in data grid getting problem
 
1 Attachment(s)
1. Not showing in Data grid
2. Not Saving in DB20

viv345 12Aug2010 17:36

Re: Time calculation add/delete in data grid getting problem
 
And if I like to calculate the Grand Total of all Totals in a grid. HOW?

virxen 13Aug2010 04:43

Re: Time calculation add/delete in data grid getting problem
 
1 Attachment(s)
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

viv345 14Aug2010 19:04

Re: Time calculation add/delete in data grid getting problem
 
2 Attachment(s)
Thanks!
I tried the same but giving problem

viv345 14Aug2010 19:37

Re: Time calculation add/delete in data grid getting problem
 
Sir
And code given for calculating column what i do if i had to calculate Rows

virxen 15Aug2010 04:22

Re: Time calculation add/delete in data grid getting problem
 
Quote:

Originally Posted by viv345 (Post 71522)
Thanks!
I tried the same but giving problem

did you connect the database correctly from the properties of Adodc1?


All times are GMT +5.5. The time now is 21:49.