'如出現雜訊,請改以Chrome 開啓
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim msg = ""
'陣列
Dim na() = {"趙一", "林二", "張三", "李四", "王五", "方六", "白七", "周八", "陳九"}
Dim ch() = {90, 100, 60, 75, 50, 80, 99, 88, 0}
''平均
Dim s = 0
For i = 0 To na.Length - 1
s = s + ch(i)
Next
msg = msg & "平均:" & Int(s / na.Length + 0.5) & "分" & vbNewLine
'最高分
Dim ma = ch(0)
For i = 1 To na.Length - 1
If ch(i) > ma Then ma = ch(i)
Next
msg = msg & "最高:" & ma & "分" & vbNewLine
'最低分
Dim mi = ch(0)
For i = 1 To na.Length - 1
If ch(i) < mi Then mi = ch(i)
Next
msg = msg & "最低:" & mi & "分" & vbNewLine
'李四考?
Dim ss = "李四"
Dim sn = ""
Dim isfound = False
For i = 0 To na.Length - 1
If na(i) = ss Then
sn = ch(i)
isfound = True
Exit For
End If
Next
If isfound = True Then
msg = msg & ss & ":" & sn & "分" & vbNewLine
End If
msg = msg & vbNewLine
'80分以上有多少人?
Dim c = 0
For i = 0 To na.Length - 1
If ch(i) >= 80 Then c = c + 1
Next
msg = msg & "80分以上有" & c & "人" & vbNewLine
'80分以上是那些人?
For i = 0 To na.Length - 1
If ch(i) >= 80 Then msg = msg & na(i) & "考" & ch(i) & "分" & vbNewLine
Next
MsgBox(msg)
End
End Sub
End Class
沒有留言:
張貼留言