简单的vb模拟选举小程序
题目是:张三,李四,王五,赵六,代号分别为1,2,3,4.选举人直接键入候选人的代号,1~4之外的数视为弃权票,点击投票按钮进行投票。点击“统计”结果按钮。打印得候选人的...
题目是:张三,李四,王五,赵六,代号分别为1,2,3,4.选举人直接键入候选人的代号,1~4之外的数视为弃权票,点击投票按钮进行投票。点击“统计”结果按钮。打印得候选人的得票和当选人的名单。
展开
1个回答
展开全部
Dim i(4) As String
Dim j(4) As Integer
Private Sub Command1_Click()
For n = 0 To 4
Print i(n) & ":" & j(n)
Next
End Sub
Private Sub Command2_Click()
Dim m
m = InputBox("请投票")
If m > 0 And m < 5 Then
j(m - 1) = Val(j(m - 1)) + 1
Else
j(4) = Val(j(4)) + 1
End If
End Sub
Private Sub Form_Load()
i(0) = "张三"
i(1) = "李四"
i(2) = "王五"
i(3) = "赵六"
i(4) = "弃权"
j(0) = 0
j(1) = 0
j(2) = 0
j(3) = 0
j(4) = 0
End Sub
Dim j(4) As Integer
Private Sub Command1_Click()
For n = 0 To 4
Print i(n) & ":" & j(n)
Next
End Sub
Private Sub Command2_Click()
Dim m
m = InputBox("请投票")
If m > 0 And m < 5 Then
j(m - 1) = Val(j(m - 1)) + 1
Else
j(4) = Val(j(4)) + 1
End If
End Sub
Private Sub Form_Load()
i(0) = "张三"
i(1) = "李四"
i(2) = "王五"
i(3) = "赵六"
i(4) = "弃权"
j(0) = 0
j(1) = 0
j(2) = 0
j(3) = 0
j(4) = 0
End Sub
更多追问追答
追问
谢谢,那窗体上有哪几个控件呢?
追答
两个按钮
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询