The Average Program

This miniprogram calculates the average of a row of integers.

You need 1.textarea, 2 textboxes and 1 commandbutton to get the program going.

The Code

    PUBLIC SUB Button1_Click()
     DIM text AS String
     DIM summe AS Float
     DIM mw AS Float
     DIM varianz AS Float
     DIM sigma AS Float
     DIM Liste AS String[]
     DIM Einzelwert AS String
     text = textarea1.Text
     Liste = Split(text,Chr(10))
     FOR EACH Einzelwert IN Liste
      summe = summe + Val(Einzelwert)
     NEXT
     mw = summe / Liste.Length
     textbox1.Text = mw
     varianz = 0
     FOR EACH Einzelwert IN Liste
      varianz = varianz + ((Val(Einzelwert) - mw)^2)
      PRINT Einzelwert,mw,((Val(Einzelwert) - mw)^2)
      PRINT varianz
     NEXT
    varianz = varianz / (Liste.Length - 1)
    PRINT varianz
    sigma = Sqr(varianz)
    textbox2.Text = sigma
    END

-- ReinerHoffmann - 31 Jan 2004