Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. Public Class Form1
  2.  
  3. Dim mat(1, 1) As Integer
  4.  
  5. Private Sub btnleitura_Click(sender As Object, e As EventArgs) Handles btnleitura.Click
  6.  
  7. btnmaior.Enabled = False
  8. btnmenor.Enabled = False
  9. ReDim mat(1, 1)
  10.  
  11. For i As Integer = 0 To Convert.ToInt32(txtlinhas.Text) - 1
  12.  
  13. For j As Integer = 0 To Convert.ToInt32(txtcolunas.Text) - 1
  14.  
  15. Try
  16.  
  17. mat(i, j) = InputBox("Introduza um número:")
  18.  
  19. Catch ex As Exception
  20.  
  21. MessageBox.Show("Introduza um valor numérico!", "Erro")
  22. Return
  23.  
  24. End Try
  25.  
  26. Next
  27.  
  28. Next
  29.  
  30. btnmaior.Enabled = True
  31. btnmenor.Enabled = True
  32.  
  33. End Sub
  34.  
  35. Private Sub btnmaior_Click(sender As Object, e As EventArgs) Handles btnmaior.Click
  36.  
  37. Dim maior As Integer
  38.  
  39. maior = mat(0, 0)
  40.  
  41. For i As Integer = 0 To Convert.ToInt32(txtlinhas.Text) - 1
  42.  
  43. For j As Integer = 0 To Convert.ToInt32(txtcolunas.Text) - 1
  44.  
  45. If mat(i, j) > maior Then
  46.  
  47. maior = mat(i, j)
  48.  
  49. End If
  50.  
  51. Next
  52.  
  53. Next
  54.  
  55. MessageBox.Show("O maior valor da matriz é o " & maior & ".", "Maior", MessageBoxButtons.OK, MessageBoxIcon.Information)
  56.  
  57. End Sub
  58.  
  59. Private Sub btnmenor_Click(sender As Object, e As EventArgs) Handles btnmenor.Click
  60.  
  61. Dim menor As Integer
  62.  
  63. menor = mat(0, 0)
  64.  
  65. For i As Integer = 0 To Convert.ToInt32(txtlinhas.Text) - 1
  66.  
  67. For j As Integer = 0 To Convert.ToInt32(txtcolunas.Text) - 1
  68.  
  69. If mat(i, j) < menor Then
  70.  
  71. menor = mat(i, j)
  72.  
  73. End If
  74.  
  75. Next
  76.  
  77. Next
  78.  
  79. MessageBox.Show("O menor valor da matriz é o " & menor & ".", "Maior", MessageBoxButtons.OK, MessageBoxIcon.Information)
  80.  
  81.  
  82.  
  83. End Sub
  84. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement