Hello.
I opened a topic before but people misunderstood my question.
I have to create a program that computes Standard Deviation of a group of numbers when Button1 is clicked. On button click, Inputbox asks for how many numbers in the group and then the calculated stDev Result should be shown in textbox1.
In the coding part, Calculation part should be made in function and the function should bring the answer in textbox1. ( Example: Textbox1.text = StDevFunc(array) )
I managed to write a code without using Function. All I need to do is to create a function and bring the calculation part inside function and then call the function when textbox1.text = answer
Obligations:
1.Array must be used.
2.Function must be used
Dim a,sum,sserror,fvar,dSD As Decimal
Integer.Tryparse(Inputbox("Enter number"),a)
a = int(Rnd()*100)
Dim array(a-1) As Integer
For i=0 to a-1
array(i) = 5
Next
For j=0 to a-1
sum = sum + array(j)
Next
avg= sum/a
For k=0 to a-1
sserror = sserror + (array(k) - avg)*2
Next
dVar= sse / a 'calculates variance
dSD = dVar / 2 ' calculates st.deviation
ALL HELP APPRECIATED AND +++++++++++
I opened a topic before but people misunderstood my question.
I have to create a program that computes Standard Deviation of a group of numbers when Button1 is clicked. On button click, Inputbox asks for how many numbers in the group and then the calculated stDev Result should be shown in textbox1.
In the coding part, Calculation part should be made in function and the function should bring the answer in textbox1. ( Example: Textbox1.text = StDevFunc(array) )
I managed to write a code without using Function. All I need to do is to create a function and bring the calculation part inside function and then call the function when textbox1.text = answer
Obligations:
1.Array must be used.
2.Function must be used
Quote:
Dim a,sum,sserror,fvar,dSD As Decimal
Integer.Tryparse(Inputbox("Enter number"),a)
a = int(Rnd()*100)
Dim array(a-1) As Integer
For i=0 to a-1
array(i) = 5
Next
For j=0 to a-1
sum = sum + array(j)
Next
avg= sum/a
For k=0 to a-1
sserror = sserror + (array(k) - avg)*2
Next
dVar= sse / a 'calculates variance
dSD = dVar / 2 ' calculates st.deviation