KEMBAR78
Suma de Matrices en Visual Basic Usando Data Grid View | PDF
0% found this document useful (0 votes)
103 views1 page

Suma de Matrices en Visual Basic Usando Data Grid View

This document describes how to sum matrices in Visual Basic using a DataGridView. It defines three 3x3 matrices to hold the values of two input matrices and the resulting summed matrix. It includes subroutines to load the values of each input matrix from the DataGridView into its respective array, and to sum the arrays element-wise, storing the results back in the third output array and DataGridView. The button click event handler calls the subroutines to perform the full matrix summation when clicked.

Uploaded by

Alexandra Enciso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views1 page

Suma de Matrices en Visual Basic Usando Data Grid View

This document describes how to sum matrices in Visual Basic using a DataGridView. It defines three 3x3 matrices to hold the values of two input matrices and the resulting summed matrix. It includes subroutines to load the values of each input matrix from the DataGridView into its respective array, and to sum the arrays element-wise, storing the results back in the third output array and DataGridView. The button click event handler calls the subroutines to perform the full matrix summation when clicked.

Uploaded by

Alexandra Enciso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Suma de Matrices en Visual Basic Usando Data Grid View

Public Class Form1


Dim matrizA(3, 3) As Single
Dim matrizB(3, 3) As Single
Dim matrizSuma(3, 3) As Single

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
For Each dtgrd In Me.Controls
If TypeOf dtgrd Is DataGridView Then
For x = 0 To 2
dtgrd.Rows.Add()
Next
End If
Next
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles Button1.Click
guardaenmatriz(matrizA, DTGA)
guardaenmatriz(matrizB, dtgb)
sumamatriz(matrizA, matrizB, matrizSuma, dtgsuma)
End Sub

Sub guardaenmatriz(ByVal matriz, ByVal data1)


For x = 0 To 2
For y = 0 To 2
matriz(x, y) = data1.Rows.Item(x).Cells(y).Value()
Next
Next
End Sub

Sub sumamatriz(ByVal A, ByVal B, ByVal Resul, ByVal data)


For x = 0 To 2
For y = 0 To 2
Resul(x, y) = A(x, y) + B(x, y)
data.Rows.Item(x).Cells(y).Value() = Resul(x, y)
Next
Next
End Sub
End Class

You might also like