vb6.0编程:输入10个数据,统计其中正数,负数和零的个数(要求用多分值语句做)……求大神解答,谢谢啦
2个回答
展开全部
Private Sub Form_Load()
Dim i As Integer, n As Double
Dim n1 As Long, n2 As Long, n3 As Long
For i = 1 To 10
n = Val(InputBox("请输入第" & i & "个数"))
If n > 0 Then
n1 = n1 + 1
ElseIf n < 0 Then
n2 = n2 + 1
Else
n3 = n3 + 1
End If
Next
MsgBox "正数" & n1 & "个,负数" & n2 & "个,零" & n3 & "个"
End Sub
Dim i As Integer, n As Double
Dim n1 As Long, n2 As Long, n3 As Long
For i = 1 To 10
n = Val(InputBox("请输入第" & i & "个数"))
If n > 0 Then
n1 = n1 + 1
ElseIf n < 0 Then
n2 = n2 + 1
Else
n3 = n3 + 1
End If
Next
MsgBox "正数" & n1 & "个,负数" & n2 & "个,零" & n3 & "个"
End Sub
展开全部
加一个按钮,加入下面程序,若满意请及时采纳,谢谢
Private Sub Command1_Click()
Dim num As Integer
Dim fl(-1 To 1) As Integer
For i = 1 To 10
num = InputBox("输入第" & i & "个数")
If num > 0 Then
fl(1) = fl(1) + 1
ElseIf num = 0 Then
fl(0) = fl(0) + 1
Else
fl(-1) = fl(-1) + 1
End If
Next i
MsgBox ("正数:" & fl(1) & "个,0:" & fl(0) & "个,负数:" & fl(-1))
End Sub
Private Sub Command1_Click()
Dim num As Integer
Dim fl(-1 To 1) As Integer
For i = 1 To 10
num = InputBox("输入第" & i & "个数")
If num > 0 Then
fl(1) = fl(1) + 1
ElseIf num = 0 Then
fl(0) = fl(0) + 1
Else
fl(-1) = fl(-1) + 1
End If
Next i
MsgBox ("正数:" & fl(1) & "个,0:" & fl(0) & "个,负数:" & fl(-1))
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询