Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim mat(1, 1) As Integer
- Private Sub btnleitura_Click(sender As Object, e As EventArgs) Handles btnleitura.Click
- btnmaior.Enabled = False
- btnmenor.Enabled = False
- ReDim mat(1, 1)
- For i As Integer = 0 To Convert.ToInt32(txtlinhas.Text) - 1
- For j As Integer = 0 To Convert.ToInt32(txtcolunas.Text) - 1
- Try
- mat(i, j) = InputBox("Introduza um número:")
- Catch ex As Exception
- MessageBox.Show("Introduza um valor numérico!", "Erro")
- Return
- End Try
- Next
- Next
- btnmaior.Enabled = True
- btnmenor.Enabled = True
- End Sub
- Private Sub btnmaior_Click(sender As Object, e As EventArgs) Handles btnmaior.Click
- Dim maior As Integer
- maior = mat(0, 0)
- For i As Integer = 0 To Convert.ToInt32(txtlinhas.Text) - 1
- For j As Integer = 0 To Convert.ToInt32(txtcolunas.Text) - 1
- If mat(i, j) > maior Then
- maior = mat(i, j)
- End If
- Next
- Next
- MessageBox.Show("O maior valor da matriz é o " & maior & ".", "Maior", MessageBoxButtons.OK, MessageBoxIcon.Information)
- End Sub
- Private Sub btnmenor_Click(sender As Object, e As EventArgs) Handles btnmenor.Click
- Dim menor As Integer
- menor = mat(0, 0)
- For i As Integer = 0 To Convert.ToInt32(txtlinhas.Text) - 1
- For j As Integer = 0 To Convert.ToInt32(txtcolunas.Text) - 1
- If mat(i, j) < menor Then
- menor = mat(i, j)
- End If
- Next
- Next
- MessageBox.Show("O menor valor da matriz é o " & menor & ".", "Maior", MessageBoxButtons.OK, MessageBoxIcon.Information)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement