Public Class 例5_5

    Private Sub 例5_5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a(10) As Integer
        Dim x As Integer, i As Integer
        Do                                          '键入-1表示全部数据输入完毕
            x = InputBox("请输入选票")
            If x >= 1 And x <= 10 Then
                a(x) = a(x) + 1                   '统计选票
            End If
        Loop While x <> -1
        Console.Write("候选人" & vbTab)
        Console.WriteLine("得票数")
        For i = 1 To 10                           '输出选票
            Console.Write(i & vbTab & vbTab)   'vbTab跳格键,为了输出对齐
            Console.WriteLine(a(i))
        Next i

    End Sub
End Class