请问VB编程这道题怎么做? 输入一批数值型非负数据,在窗体上显示出来
Private Sub Command1_Click()
Static sglArray() As Single
Static intDataCount As Integer, sglSum As Single, sglAverage As Single
Dim i As Integer, sglVariance As Single, sglShandardDeviataion As Single
intDataCount = intDataCount + 1
ReDim Preserve sglArray(intDataCount)
sglArray(intDataCount) = InputBox("请输入第" & intDataCount & "一个非负数:", "数据录入", 0)
Me.List1.AddItem "a(" & intDataCount & ")=" & sglArray(intDataCount)
sglSum = sglSum + sglArray(intDataCount)
sglAverage = sglSum / intDataCount
For i = 1 To intDataCount
sglVariance = sglVariance + (sglArray(i) - sglAverage) ^ 2
Next i
sglShandardDeviataion = Sqr(sglVariance / intDataCount)
Me.Label1.Caption = sglSum
Me.Label2.Caption = Me.List1.ListCount
Me.Label3.Caption = sglSum / intDataCount
Me.Label4.Caption = sglShandardDeviataion
End Sub