Como Sumar las filas de un MSFlexGrid
Hola,
ejecuta este ejemplo, necesitas un mflexgrid y un commandbutton.
Sub cargarGrid()
Me.mfGrid.AllowUserResizing = 3
'Número de columnas fijas
mfGrid.FixedCols = 0
'Número de filas fijas
mfGrid.FixedRows = 0
'Mostramos el Scroll horizaontal y el vertical
mfGrid.ScrollBars = 3
'Numero de Filas
mfGrid.Rows = 1
mfGrid.FocusRect = flexFocusLight
mfGrid.GridLines = flexGridRaised
'Numero de Columnas a mostrar
ReDim FixedColCaptions(3)
'Cabecera
FixedColCaptions(0) = "ID"
FixedColCaptions(1) = "NOMBRE"
FixedColCaptions(2) = "CANTIDAD"
'Nos situamos en la fila 0
mfGrid.Row = 0
'Numero de Columnas
mfGrid.Cols = 3
Dim j As Long
Dim k As Long
Dim i As Integer
'Rellenamos la cabecera de la filas fijas
For j = 0 To mfGrid.Cols - 1
mfGrid.Col = j
mfGrid.Text = FixedColCaptions(j)
mfGrid.HighLight = flexHighlightWithFocus
mfGrid.CellBackColor = RGB(100, 255, 0)
Next
mfGrid.AddItem "1" & vbTab & "Francisco" & vbTab & "3568"
mfGrid.AddItem "2" & vbTab & "Fernando" & vbTab & "125"
mfGrid.AddItem "3" & vbTab & "Sergio" & vbTab & "256"
mfGrid.AddItem "4" & vbTab & "Emilio" & vbTab & "1258"
mfGrid.AddItem "5" & vbTab & "Ignacio" & vbTab & "945"
mfGrid.AddItem "6" & vbTab & "Manolo" & vbTab & "56"
End Sub
Private Sub Command1_Click()
Dim j As Long
Dim suma As Double
For j = 1 To mfGrid.Rows - 1
mfGrid.Row = j
suma = suma + CDbl(mfGrid.TextMatrix(j, 2))
Next j
MsgBox "La suma total es " & suma
End Sub
Private Sub Form_Load()
cargarGrid
End Sub
salu2
sdemingo
http://boards.melodysoft.com/sdemingo
ejecuta este ejemplo, necesitas un mflexgrid y un commandbutton.
Sub cargarGrid()
Me.mfGrid.AllowUserResizing = 3
'Número de columnas fijas
mfGrid.FixedCols = 0
'Número de filas fijas
mfGrid.FixedRows = 0
'Mostramos el Scroll horizaontal y el vertical
mfGrid.ScrollBars = 3
'Numero de Filas
mfGrid.Rows = 1
mfGrid.FocusRect = flexFocusLight
mfGrid.GridLines = flexGridRaised
'Numero de Columnas a mostrar
ReDim FixedColCaptions(3)
'Cabecera
FixedColCaptions(0) = "ID"
FixedColCaptions(1) = "NOMBRE"
FixedColCaptions(2) = "CANTIDAD"
'Nos situamos en la fila 0
mfGrid.Row = 0
'Numero de Columnas
mfGrid.Cols = 3
Dim j As Long
Dim k As Long
Dim i As Integer
'Rellenamos la cabecera de la filas fijas
For j = 0 To mfGrid.Cols - 1
mfGrid.Col = j
mfGrid.Text = FixedColCaptions(j)
mfGrid.HighLight = flexHighlightWithFocus
mfGrid.CellBackColor = RGB(100, 255, 0)
Next
mfGrid.AddItem "1" & vbTab & "Francisco" & vbTab & "3568"
mfGrid.AddItem "2" & vbTab & "Fernando" & vbTab & "125"
mfGrid.AddItem "3" & vbTab & "Sergio" & vbTab & "256"
mfGrid.AddItem "4" & vbTab & "Emilio" & vbTab & "1258"
mfGrid.AddItem "5" & vbTab & "Ignacio" & vbTab & "945"
mfGrid.AddItem "6" & vbTab & "Manolo" & vbTab & "56"
End Sub
Private Sub Command1_Click()
Dim j As Long
Dim suma As Double
For j = 1 To mfGrid.Rows - 1
mfGrid.Row = j
suma = suma + CDbl(mfGrid.TextMatrix(j, 2))
Next j
MsgBox "La suma total es " & suma
End Sub
Private Sub Form_Load()
cargarGrid
End Sub
salu2
sdemingo
http://boards.melodysoft.com/sdemingo
