Hello all,
I am new to VB and need to make a program that does the following:

Write a VB.Net program that allows users to enter a series of numbers
(separated by a comma) in a text box called series. When the users clicks the command button called Average, the program extracts the number one by one from the series and calculates the average, and outputs the average onto a textbox called Result.

I understand how to get it to do the average, but how can I make the program count the numbers that I input and then divided by the sum? Also, how would i get it started.

Any help will be appreciated.

7 Years
Discussion Span
Last Post by Phen0

I wouldn't suggest doing this as a 1-liner (as shown below) but to give you an idea:

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
    Dim s As String = "1,2,3,4,5,6,7,8,9,10,11,12"
    Dim avg As Double = s.Split(",").ToList().ConvertAll(New Converter(Of String, Integer)(AddressOf Convert.ToInt32)).Average()
  End Sub

When running your program there was a build array saying that Error 'ToList' is not a member of 'System.Array'.

Also, I haven't learned array yet in class so I want to avoid if possible.

This is what i have:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Integer
        Dim s As Double
        Dim resultstring As String
        Dim anumericvalue As Double

        s = 0
        For i = 0 To List.items.count - 1
            s = s + List.items.item(i)
        Next i
        resultstring = Str(s / List.items.count)
        result1.Text = "average is: " & resultstring
    End Sub

But the build errors i have are all dealing with List.
IE Error Too few type arguments to 'System.Collections.Generic.List(Of T)'.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.