Hello guys, I can't seem to be able to calculate the datagrid with only 1 record. Instead, I can calculate my records in datagrid accurately. how come/ What shall i do?

Dim no_of_row As Integer
Dim i As Integer
Dim sum As Currency
no_of_row = frmmain.dgditem.VisibleRows


If no_of_row <> 1 Then
For i = 0 To no_of_row - 1
frmmain.dgditem.Row = i
sum = sum + frmmain.dgditem.Columns("Quantity") * frmmain.dgditem.Columns("Price")
Next i
End If

frmmain.lbltotalcost.Caption = Format(sum, "$#.00")