Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anyone have the answer to these 2 questions?

Status
Not open for further replies.

piscis

Programmer
Jun 26, 2003
29
PR
Gentlemen:

Does anyone have the answer to these 2 questions?

1. How to sum only those records for the month of March in column 4 in datagrid1 and display it in a textbox3 located in a Tab Control #2 named “Ventas”
2. How to sum ALL records in column 4 in datagrid1 and display it in textbox8 located in a Tab Control #2 named “Ventas”

Thanks

Andy
 
Have you tried a For Each?

For Each row in DataRow ...

total = total + ColumnValue

End For

Ventas.txt = total

 
Do you know why I'm getting this error?

On this line:
If IsNumeric(Me.Item(row, col)) Then

Error: Item is not a member of Project.frmMain'

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim ds As DataSet = Me.DsBrio250Table5
'where "Me" is the datagrid
Dim rowCount As Integer = ds.Tables(0).Rows.Count()
Dim col As Integer = 4
Dim row As Integer
Dim dsum As Double

For row = 0 To rowCount - 1
If IsNumeric(Me.Item(row, col)) Then
dsum = dsum + CLng(IIf(IsDBNull(Me.Item(row, col)), "0", Me.Item(row, col)))
End If
Next row
End Sub
 
"Me" is reserved for your Form. Use the name of your DataGrid instead.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top