Advertisement
Guest User

sopt

a guest
Jun 14th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.13 KB | None | 0 0
  1.  
  2. ' Não se esqueça de importar está linha abaixo!
  3. Imports System.Collections
  4.  
  5. Public Class Form1
  6.     Dim numeros As New ArrayList
  7.     Dim total As Integer = 0
  8.  
  9.     ' Botão CONFIRMAR
  10.     Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  11.         If IsNumeric(txtboxnum.Text) Then
  12.             numeros.Add(txtboxnum.Text)
  13.             txtboxnum.Clear()
  14.         Else
  15.             MessageBox.Show("Atenção, introduza um NÚMERO")
  16.             txtboxnum.Focus()
  17.             Return
  18.         End If
  19.  
  20.     End Sub
  21.  
  22.     ' Obtém o maior número
  23.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  24.         Dim maiorNumero As Integer = 0
  25.         For Each numero As Integer In numeros
  26.             total += numero
  27.             maiorNumero = Math.Max(maiorNumero, numero)
  28.         Next
  29.  
  30.         txtMaior.Text = maiorNumero.ToString()
  31.     End Sub
  32.  
  33.     ' Obtém a MÉDIA
  34.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  35.         Dim media As Integer = total / numeros.Count
  36.  
  37.         txtMedia.Text = media.ToString()
  38.     End Sub
  39. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement