Hello! I want to add something to this code.

I want to add a inputbox which asks for number count.

For example if you enter 5, then you have 5 random numbers..

Quote Originally Posted by dunfiddlin View Post
vb.net Code:
  1. Option Strict On
  2.  
  3. Public Class Form1
  4.     Dim r As New Random
  5.     Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
  6.         Dim test(7) As Decimal ' set up a test array of
  7.         For i = 0 To 7
  8.             test(i) = r.Next(11) ' random values 0 to 10
  9.         Next
  10.         Me.Text = StandardDeviation(test).ToString ' function
  11.     End Sub
  12.  
  13.     Function StandardDeviation(ByVal values() As Decimal) As Decimal
  14.         Dim Mean As Decimal = values.Sum / values.Length ' get average of all array values
  15.         Dim Diff As Decimal
  16.         For Each d In values
  17.             Diff = CDec(Diff + ((d - Mean) ^ 2)) ' calculate difference squares & sum them
  18.         Next
  19.         Return CDec(Math.Sqrt(Diff / values.Length)) ' return deviation
  20.     End Function
  21. End Class