0
數據樣本:20.50和20.00 合計:41.00DataGridView的總和列錯誤/ vb.net
我怎樣才能得到確切數量,因爲40.50?我可以對列進行求和並顯示標籤,但是我無法解決舍入問題。
If DataGridView1.RowCount > 1 Then
Dim tutar As Integer = 0
For index As Integer = 0 To DataGridView1.RowCount - 1
total += Convert.ToInt32(DataGridView1.Rows(index).Cells(3).Value)
Next
Label1.Text = total.ToString("N2")
End If
我的錯。沒有這樣的東西'tutar'。這是'全部'。 '如果DataGridView1.RowCount> 1然後 昏暗總作爲雙人= 0 對於索引爲整數= 0要DataGridView1.RowCount - 1個 總+ = Convert.ToDouble(DataGridView1.Rows(指數).Cells(3)。 Value) Next Label1.Text = total.ToString() End If' 我試過了,並沒有工作。 – burak
沒關係。只要將'total'變成'double',或者你也可以用'decimal' ..根據你的需要。 – Codemunkeee
試過兩次或十進制。兩者都不起作用。圍繞結果四捨五入。 – burak