so the steps involved would be:
- (already done)
- 1) Enter then inputs into array via inputbox
- 2) Input to sppear in listbox
(not done) - 3) Sort the array ascending/decending
- 4) print results into the listbox again.
In my code there is also a total and a average, but that doesnt need any help on it.
Public Class Form1
Dim total As Integer
Dim array(11) As Integer
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles btnMonthlyAmmount.Click
Dim count As Integer
Dim element As Integer
Dim Month As Integer
Dim ValueEntered As Integer
Dim ValueFormatted As Object
count = 0
Month = 1
While count <= UBound(array)
ValueEntered = Int(InputBox("Please enter the monthly total: "))
ValueFormatted = ("Month " & Month & ": " & ValueEntered)
array(count) = ValueEntered
ListBox1.Items.Add(ValueFormatted)
count = (count + 1)
Month = Month + 1
End While
If count > UBound(array) Then
btnMonthlyAmmount.Enabled = False
End If
For Each element In array
total = total + element
Next element
End Sub
Private Sub btnYearlyUsageCalc_Click(sender As System.Object, e As System.EventArgs) Handles btnYearlyUsageCalc.Click
lblTotalUseageYear.Text = total
End Sub
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
lblMonthlyUsedAverage.Text = total / array.Length
End Sub
End Class
Thanks in advance.
ps. have looked at other code example via google, but can't get my head around the.

New Topic/Question
Reply



MultiQuote




|