Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Command3_Click()
- '3.某班學生人數不詳,欲輸入每一個學生的VB成績,當輸入-1 時表示結束輸入,然後計算全班人數?,及格人數?,不及格人數?,及全班平均分數?
- Cls
- Dim count As Integer
- Dim good As Integer
- Dim bad As Integer
- Dim sum As Integer
- n = InputBox("輸入分數")
- Do While n <> -1
- sum = sum + n
- count = count + 1
- If n <= 100 And n >= 60 Then
- good = good + 1
- ElseIf n >= 0 Then
- bad = bad + 1
- End If
- n = InputBox("輸入分數")
- Loop
- Print "全班人數為:"; count
- Print "及格人數為:"; good
- Print "不及格人數為:"; bad
- Print "全班平均為:"; sum / count
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement