Create an application that ask you “how many nos you would like to enter=
Enter all the nos by Input box / text box (dynamic generate) when you
click on ‘result’ button following things should be display.
List box 1:original nos.
List box 2: nos in ascending.
List box 3: nos in descending.
Label: the sum of all entered nos
Label: the average of all entered nos.
Public Class app6
Dim a() As Integer
Dim i, x, r As Integer
Dim sname(2) As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
i = CInt(TextBox1.Text)
ReDim a(i)
For x = 0 To Val(TextBox1.Text) - 1
a(x) = InputBox("Enter Number=")
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'System.Array.Sort(a)
For x = 0 To a.Length - 2
ListBox1.Items.Add(a(x))
Next
System.Array.Sort(a)
'-------------ascending---------------
For x = 1 To a.Length - 1
ListBox2.Items.Add(a(x))
Next
'-----------descending----------
For x = ListBox2.Items.Count - 1 To 0 Step -1
ListBox3.Items.Add(ListBox2.Items(x))
Next
'----------- sum of numbers----------
Dim sum As Integer = 0
For x = 0 To a.Length - 1
r = (a(x))
sum = sum + r
Next
Label6.Text = sum
'----------- Average ------------
Label8.Text = sum / i
End Sub
End Class
Made By: Yadav Roshani R. from Third Year of BCA
Comments
Post a Comment