I need to create the code for a user to enter with an indeterminate number of numbers and then see the largest of the numbers and make their average.
Each entry is made by clicking on the Confirm button (done in design ) < I then created a variable y
that will accumulate the values.
When the "major" button is pressed, it places the largest of the numbers on another textbox
made to the result. The average button should give the average (also in the textbox
of the result) of the numbers that have entered so far.
It's a more or less simple problem, I think, but it needed a little help. I have attached what I have done in code.
Public Class Form1
Dim y As Integer
Private Sub btnconfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnconfirm.Click
Dim numeros(txtboxnum.Text) As Integer
If IsNumeric(txtboxnum.Text) Then
y = y + 1
txtboxnum.clear()
Else
MessageBox.Show("Atenção, introduza um NÚMERO")
Return
txtboxnum.Focus()
End If
End Sub
Private Sub btnmaior_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmaior.Click
Dim maior As String
For c = 0 To txtboxnum.Text.Length - 1
If txtboxnum.Text(y) > maior Then
maior = txtboxnum.Text(y)
End If
Next
txtboxresult.Text = maior
End Sub
Private Sub btnmedia_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmedia.Click
For c = 0 To txtboxnum.Text.Length - 1
Next
End Sub
Private Sub btnnovosnums_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnovosnums.Click
txtboxnum.Clear()
txtboxresult.Clear()
End Sub
End Class