[go: up one dir, main page]

0% found this document useful (0 votes)
67 views6 pages

VB - Matrices

This document describes a program for performing operations on matrices. It includes: 1) The design of a form with text boxes and data grids to input matrix sizes and display results. 2) The coding of the program in Visual Basic, including buttons to populate the grids, add, subtract and find sums, maximums, minimums of matrices. 3) Notes that the program was executed to operate on matrices as entered by the user.

Uploaded by

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

VB - Matrices

This document describes a program for performing operations on matrices. It includes: 1) The design of a form with text boxes and data grids to input matrix sizes and display results. 2) The coding of the program in Visual Basic, including buttons to populate the grids, add, subtract and find sums, maximums, minimums of matrices. 3) Notes that the program was executed to operate on matrices as entered by the user.

Uploaded by

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

Universidad Tecnológica de Panamá

Facultad de Ingeniería Civil

Programación

Tarea Nº6

Tema:

Matrices

Nombre:

Dayana Castrejón

Cédula:

8-922-714

Grupo:

1IC124

Profesor:

Emilio Batista

Fecha:

Junio 17,2017
Tarea Nº6

Matrices

A. Diseño del Formulario

B. Codificación del Programa


Public Class Form1
Dim Fila As Byte, Columna As Byte, i As Byte

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
Dim i, Tamaño As Integer
Fila = Val(TextBox1.Text)
Columna = Val(TextBox2.Text)
Tamaño = 40
DGA.RowCount = Fila
DGA.ColumnCount = Columna
DGB.RowCount = Fila
DGB.ColumnCount = Columna
DGR.RowCount = Fila
DGR.ColumnCount = Columna

For i = 0 To columna - 1 Step 1


DGA.Columns(i).HeaderText = i + 1
DGA.Columns(i).Width = Tamaño
DGB.Columns(i).HeaderText = i + 1
DGB.Columns(i).Width = Tamaño
DGR.Columns(i).HeaderText = i + 1
DGR.Columns(i).Width = Tamaño
Next

For i = 0 To fila - 1 Step 1


DGA.Rows(i).HeaderCell.Value = (i + 1).ToString + "Fila"
DGB.Rows(i).HeaderCell.Value = (i + 1).ToString + "Fila"
DGR.Rows(i).HeaderCell.Value = (i + 1).ToString + "Fila"
Next
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
Dim i, j As Byte
Fila = Val(TextBox1.Text)
Columna = Val(TextBox2.Text)
For i = 0 To Fila - 1 Step 1
For j = 0 To Columna - 1 Step 1
DGR.Rows(i).Cells(j).Value = Val(DGA.Rows(i).Cells(j).Value) +
Val(DGB.Rows(i).Cells(j).Value)
Next j
Next i
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles


Button3.Click
Dim i, j As Byte
Fila = Val(TextBox1.Text)
Columna = Val(TextBox2.Text)
For i = 0 To Fila - 1 Step 1
For j = 0 To Columna - 1 Step 1
DGR.Rows(i).Cells(j).Value = Val(DGA.Rows(i).Cells(j).Value) -
Val(DGB.Rows(i).Cells(j).Value)
Next j
Next i
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles


Button5.Click
Dim i, j As Byte
Dim DA, DB, SumaA, SumaB As Integer
DA = 0
DB = 0
SumaA = 0
SumaB = 0

Fila = Val(TextBox1.Text)
Columna = Val(TextBox2.Text)

For i = 0 To Fila - 1 Step 1


For j = 0 To Columna - 1 Step 1
SumaA = SumaA + Val(DGA.Rows(i).Cells(j).Value)
SumaA = SumaB + Val(DGB.Rows(i).Cells(j).Value)

If i = j Then
DA = DA + Val(DGA.Rows(i).Cells(j).Value)
DB = DB + Val(DGB.Rows(i).Cells(j).Value)

End If
TextBox3.Text = DA
TextBox4.Text = DB
TextBox9.Text = SumaA
TextBox10.Text = SumaB
Next
Next
End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles


Button6.Click
Dim i, j As Byte
Dim MxA, MxB As Integer

Fila = Val(TextBox1.Text)
Columna = Val(TextBox2.Text)

For j = 0 To Columna - 1 Step 1


For i = 0 To Columna - 1 Step 1
If DGA.Rows(i).Cells(j).Value > MxA Then
MxA = DGA.Rows(i).Cells(j).Value
End If
Next i
Next j

For j = 0 To Columna - 1 Step 1


For i = 0 To Columna - 1 Step 1
If DGB.Rows(i).Cells(j).Value > MxB Then
MxB = DGB.Rows(i).Cells(j).Value
End If
Next i
Next j

TextBox5.Text = MxA
TextBox6.Text = MxB
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


Me.Text = "Operaciones con Matrices"
Label1.Text = Environ("COMPUTERNAME")
Label2.Text = Environ("USERNAME")
End Sub

Private Sub Button7_Click(sender As Object, e As EventArgs) Handles


Button7.Click
Dim i, j As Byte
Dim MnA, MnB As Integer
MnA = Val(DGA.Rows(i).Cells(j).Value)
MnB = Val(DGB.Rows(i).Cells(j).Value)
Fila = Val(TextBox1.Text)
Columna = Val(TextBox2.Text)

For i = 0 To Fila - 1 Step 1


For j = 0 To Columna - 1 Step 1
If Val(DGA.Rows(i).Cells(j).Value) < MnA Then
MnA = Val(DGA.Rows(i).Cells(j).Value)
End If
If Val(DGB.Rows(i).Cells(j).Value) < MnB Then
MnB = Val(DGB.Rows(i).Cells(j).Value)
End If
Next j
Next i
TextBox7.Text = MnA
TextBox8.Text = MnB
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles


Button4.Click
DGA.Rows.Clear()
DGA.RowCount = 10
i = 0
DGB.Rows.Clear()
DGB.RowCount = 10
i = 0
DGR.Rows.Clear()
DGR.RowCount = 10
i = 0

TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
End Sub
End Class

C. Programa Ejecutado

You might also like