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