|
Postada em 22/11/2006 14:51 hs
caros amigos.... estou tentando somar uma coluna da DAtagrid, mas ta dando erro, pelo q vi, na hora q o loop chega no final da tabela... vejam o codigo q to usando: -------------------------------------------------- 'faz a soma dos creditos Dim i As Integer Dim SomaCred As Double SomaCred = "0" DataGrid1.Col = 4 ' coluna a ser somada For i = 0 To DataGrid1.ApproxCount - 1 DataGrid1.Row = i ( O ERRO OCORRE NESTA LINHA) SomaCred = CCur(DataGrid1.Columns(10).Text) + SomaCred Next Label3.Caption = Format(SomaCred, "0.00") -------------------------------------------------------------------- Run-time error '6148" Invalid row number se alguem puder me ajudar, agradeço!!!!
|
|
|
|
PH1959
|
SÃO JOSÉ DOS CAMPOS SP - BRASIL
|
|
Postada em 22/11/2006 15:13 hs
Dim i As Integer Dim SomaCred As Double SomaCred = "0" For i = 0 To DataGrid1.ApproxCount - 1 SomaCred = CCur(DataGrid1.Columns(4).CellValue(DataGrid1.SelBookmarks(i)) + SomaCred Next i Label3.Caption = Format(SomaCred, "0.00")
|
|
|
|
Postada em 22/11/2006 15:26 hs
eu um erro: nesta linha: SomaCred = CCur(DataGrid1.Columns(4).CellValue(DataGrid1.SelBookmarks(i))) + SomaCred erro: run-time error '9' subscript out of range
|
|
|
PH1959
|
SÃO JOSÉ DOS CAMPOS SP - BRASIL
|
|
Postada em 22/11/2006 16:05 hs
substitui no for.. for i=0 to DataGrid1.SelBookmarks.Count -1
|
|
|
|
Postada em 22/11/2006 16:15 hs
coloquei o codigo assim: Dim i As Integer Dim SomaCred As Double SomaCred = "0" 'For i = 0 To DataGrid1.ApproxCount - 1 For i = 0 To DataGrid1.SelBookmarks.Count - 1 SomaCred = CCur(DataGrid1.Columns(10).CellValue(DataGrid1.SelBookmarks(i))) + SomaCred MsgBox SomaCred Next i Label3.Caption = Format(SomaCred, "0.00")
mas nao apareceu o somatorio, ate coloquie um MSGBOX pra ver se tava rodando algo, mas ele na ta passando por esse codigo, tambem nao deu erro
|
|
|