Visual Basic Averages

Discussion in 'Programming' started by Silver89, Feb 5, 2007.

  1. #1
    Hi,

    if i import data from a file into a visual basic program then want to find the mean of that data is their a code/function within vb to do this or do you have to call the numbers and do maths functions??

    Please advise

    Thanks
    Dan
     
    Silver89, Feb 5, 2007 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Just create a function to find the total, and divide by that like:

    Private Function FindAverage(ByVal Vals as ArrayList)
    Dim RetVal as Decimal = 0.0
    For x = 0 to ubound(Vals.Count)
    RetVal += Vals(x)
    next
    FindAverage = Integer.Parse((RetVal/Vals.Count) * 100)
    End Function

    (This is just quick trhown together, not tested) BUt I hope it gets you on yoru way!
     
    ccoonen, Feb 5, 2007 IP