sumar valor en glexgrid
Publicado por bsin (10 intervenciones) el 24/04/2011 05:48:45
Compañeros: Tengo un flexgrid que necesito recorrer , sumar los valores y que me los muestre en una columna del flexgrid, ejemplo:
Total Col1 Col2 Col3 Col4 Col5 Col6
0 1 1 1 0 1
0 0 0 0 1 1
1 1 1 0 1 1
1 1 1 1 1 1
La celda del primer total es 4, segundo 2, tercero 5, cuarto 6, etc., no se porque no me funciona este código, o si hay otra forma de hacerlo.
Public Sub contarr()
Dim cell As String
Dim fila As Double
Dim col As Double
Grid1.col = 0
Grid1.Row = 0
For fila = 1 To Grid1.Rows - 1
Grid1.col = 0
Grid1.Row = fila
For col = 1 To Grid1.Cols - 1
Grid1.col = col
Grid1.Row = 0
Grid1.Row = fila
Grid1.col = col
cell = Grid1.TextMatrix(fila, col)
If cell <> "" then
cell = 1
Else
cell = 0
End If
Grid1.TextMatrix(fila, 0) = cell + 1
Next col
Next fila
End Sub
Total Col1 Col2 Col3 Col4 Col5 Col6
0 1 1 1 0 1
0 0 0 0 1 1
1 1 1 0 1 1
1 1 1 1 1 1
La celda del primer total es 4, segundo 2, tercero 5, cuarto 6, etc., no se porque no me funciona este código, o si hay otra forma de hacerlo.
Public Sub contarr()
Dim cell As String
Dim fila As Double
Dim col As Double
Grid1.col = 0
Grid1.Row = 0
For fila = 1 To Grid1.Rows - 1
Grid1.col = 0
Grid1.Row = fila
For col = 1 To Grid1.Cols - 1
Grid1.col = col
Grid1.Row = 0
Grid1.Row = fila
Grid1.col = col
cell = Grid1.TextMatrix(fila, col)
If cell <> "" then
cell = 1
Else
cell = 0
End If
Grid1.TextMatrix(fila, 0) = cell + 1
Next col
Next fila
End Sub
Valora esta pregunta


0