我正在开发一个 vb.net 2010 表单,它将添加用户输入。我想制作一个可以计算总和、平均值、方差和标准差的程序....任何人都可以帮助添加代码和解决问题????请帮助我......我正在尝试解决问题,但是当我运行程序时出现错误“InvalidOperationException 未处理(创建表单时发生错误。有关详细信息,请参阅 Exception.InnerException。错误是:未设置对象引用到一个对象的一个实例。)”
任何人都可以帮助我解决这个问题吗?
Public Class Form1
Dim sum As Integer
Dim mean As Double
Dim x(ListBox1.Items.Count - 1) As Integer
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim TotalN As Double = InputBox("The total Number", "Enter a number")
Dim sum As Single
Dim b As Integer = ListBox1.Items.Count - 1
Dim counter As Integer
For counter = 0 To b
x(counter) = ListBox1.Items(counter)
If (Val(x(counter)) = TotalN) Then
sum = (sum + x(counter)) / TotalN
End If
Next
End Sub
End Class