21-04-17, 02:35 AM
كود جمع عمود من Datagridview وإظهار ناتج الجمع في TextBox
*******************
كود جمع عمود من الجدول Database وإظهار ناتج الجمع في TextBox
PHP كود :
Dim Total As Double = 0
For Each row As DataGridViewRow In DataGridView1.Rows
Total += Val(row.Cells(رقم العمود).Value.ToString)
Next
TextBox1.Text = Total
كود جمع عمود من الجدول Database وإظهار ناتج الجمع في TextBox
PHP كود :
Dim sqlString As String = _
" SELECT SUM([Column name]) AS [Total1] " & _
" FROM [Table name] & ""
Using da As New OleDbDataAdapter(sqlString, connectionstring)
Using dt As New DataTable
If da.Fill(dt) > 0 Then
TextBox1.Text = (dt.Rows(0).Item("Total1").ToString)
End If
End Using
End Using

