Manual de Flexgrid y Datagrid

Page 15

61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72.

End Sub 'Función para generar valores aleatorios para insertar en el FlexGrid Private Function Numero_Aleatorio( _ Upper As Integer, _ Lower As Integer) As Integer Randomize 'Retornar el número a la función Numero_Aleatorio = Int((Upper - Lower + 1) * Rnd + Lower) End Function

EN ESTE SIMPLE EJEMPLO PASA O COPIAR EL CONTENIDO DE UN ARRAY O MATRIZ DE DATOS A UN CONTROL FLEXGRID. Antes de pasar los datos, en el ejemplo, se utiliza un array de 2 Dimensiones que previamente se carga con algunos valores en un For-next. Luego de cargarse los valores en la matriz, se llama a la sub Array_a_FlexGrid y se le envía como parámetro el Array y el control Ms FlexGid Luego dentro de la sub obtiene los valores máximos y mínimos de las dimensiones para poder, mediante un bucle For-Next llenar el Flex con el método TextMatrix del control

Controles Agegar un control FlexGid en el Formulario un Command1

Pegar el código fuente en el Form: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25.

Option Explicit

'Función que recibe como parámetro la matriz y el control FlexGrid ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub Array_a_FlexGrid(ByRef elArray() As Variant, ByVal FlexGrid As MSFlexGrid) Dim VFMin As Integer, VColMin As Integer, VFMax As Integer Dim VColMax As Integer, Fila As Integer, Columna As Integer 'Alamacena el primer y último valor de cada dimensión del array VFMin = LBound(elArray, 1) VFMax = UBound(elArray, 1) VColMin = LBound(elArray, 2) VColMax = UBound(elArray, 2) With FlexGrid .FixedCols = 0 .FixedRows = 0 'Añade las filas y columas .Rows = VFMax - VFMin + 1 .Cols = VColMax - VColMin + 1


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.