一道VB题,急要TT~~~谢谢!!!

来源:百度知道 编辑:UC知道 时间:2024/05/23 19:27:58
用inputbox函数输入10个数到数组A中,输入后将这10个数显示在某文本框中,并统计正数的个数,正数的和,负数的个数,负数的和。用print方法将结果直接打印在窗体上。 谢谢~~~~~~~TT

Private Sub Form_Click()
Dim A(10) As Integer, I As Integer
Dim Z As Integer, Zh As Integer
Dim F As Integer, Fh As Integer
Form1.AutoRedraw = True
Randomize
For I = 1 To 10
A(I) = Val(InputBox("第" & I & "个数", "输入", Int(Rnd * 100 - 50)))
Print A(I);
If I Mod 5 = 0 Then Print
If A(I) < 0 Then
F = F + 1
Fh = Fh + A(I)
ElseIf A(I) > 0 Then
Z = Z + 1
Zh = Zh + A(I)
End If
Next
Print "正数共"; Z; "个,总和是:"; Zh
Print "负数共"; F; "个,总和是:"; Fh
End Sub

已经运行过

Private Sub Command1_Click()
Dim a(10) As Integer
For I = 1 To 10
a(I) = Val(InputBox(""))
text1.Text = text1.Text & a(I) & " "
If a(I) > 0 Then x = x + 1: sumX = sumX + a(I)