0
I need to create the code for a user to enter an undetermined number of numbers and then see the largest number and average it.
Each entry is made by clicking on button "confirm" (done in the design of Form) that accumulates the values entered and then clears them, for this I created a variable y
that accumulates the values.
When the button "larger" is pressed, put on another textbox
made for the result, the largest of the numbers. The button "medium" should give the average (also in the textbox
of the result) of the numbers entered so far.
It is a problem more or less simple I think, but I needed a little help. I enclose what I did of 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
Crisp, you’ve specified everything you have to do, but haven’t clarified your real difficulty.
– Fabricio
@Fabricio my difficulty is how I do to see which is the largest number of a set of numbers introduced by the user and make the average of them
– pedrocxb
You should wear a array to store the numbers, not add them up.
– stderr