VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "选举程序"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5760
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   5760
   StartUpPosition =   3  '窗口缺省
   Begin VB.Label Label1 
      Caption         =   "候选人的票数公布如下"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   11.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   255
      Left            =   1440
      TabIndex        =   0
      Top             =   0
      Width           =   2655
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Activate()
  Dim N, R As Integer                 '声明变量N和R是整型变量
  R = Val(InputBox("请输入候选人的个数", "候选人个数", 0))   '请输入候选人的个数
  Dim P(5) As Integer             '
  N = 1: Print: Print                 '
  Do While N > 0 And N <= R           '
    N = Val(InputBox("请输入候选人的选号", "选举投票", 0))   '请输入候选人的选号
    P(N) = P(N) + 1                  '统计各候选人的选票
  Loop
  For N = 1 To 5                   '定位显示所有候选人的票数
    Print Tab(((N - 1) Mod 2) * 30 + 2); "第" & Str(N) & "个候选人的票数是："; P(N);
    If N Mod 2 = 0 Then Print      '一行显示两个候选人的票数后换行
  Next N
End Sub

 

