选票器
对象 属性 值
Form1 Text 请投票
Label1 Text 孙楠的选票为
Label2 Text 韩红的选票为
Label3 Text 李健的选票为
Button1 Text 选孙楠
Button2 Text 选韩红
Button3 Text 选李健
Button4 Text 结果是:
编写事件过程代码
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4860
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4860
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "Command3"
Height = 495
Left = 3240
TabIndex = 5
Top = 2160
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 495
Left = 1800
TabIndex = 4
Top = 2160
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 360
TabIndex = 3
Top = 2160
Width = 1215
End
Begin VB.Label Label3
Caption = "Label3"
Height = 495
Left = 360
TabIndex = 2
Top = 1440
Width = 1215
End
Begin VB.Label Label2
Caption = "Label2"
Height = 495
Left = 360
TabIndex = 1
Top = 840
Width = 1215
End
Begin VB.Label Label1
Caption = "Label1"
Height = 495
Left = 360
TabIndex = 0
Top = 240
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private a As Integer
Private b As Integer
Private c As Integer
Private Sub updatelabel()
Label1.Caption = "孙楠的选票为 " & a
Label2.Caption = "韩红的选票为 " & b
Label3.Caption = "李健的选票为 " & c
End Sub
Private Sub Command1_Click()
a = a + 1
updatelabel
End Sub
Private Sub Command2_Click()
b = b + 1
updatelabel
End Sub
Private Sub Command3_Click()
c = c + 1
updatelabel
End Sub
Private Sub Form_Load()
Caption = "请投票"
Command1.Caption = "选孙楠"
Command2.Caption = "选韩红"
Command3.Caption = "选李健"
a = 0
b = 0
c = 0
updatelabel
End Sub