嗨,我正在尝试在 vb.net 中创建一个程序来查找数字的平均值,仅使用一个变量作为输入框的值,第二个用于计数的数字应该是负数,但我无法得到准确的答案,这里是代码
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num, count As Integer
num = InputBox("Please enter number") 'for first entry
While num > 0 ' here we have to check it that the num is not negative then to start
num = InputBox("Please enter number")
num += num
count += 1 'this will calculate how many times number added
End While
MsgBox("Average is " & num / count)
End Sub