5.6.frm
来自「VB6.0应用例题」· FRM 代码 · 共 90 行
FRM
90 行
VERSION 5.00
Begin VB.Form Form1
Caption = "列表框应用示例"
ClientHeight = 2925
ClientLeft = 2025
ClientTop = 3540
ClientWidth = 3690
LinkTopic = "Form1"
ScaleHeight = 2925
ScaleWidth = 3690
Begin VB.CommandButton CommandDelete
Caption = "删 除"
Enabled = 0 'False
Height = 495
Left = 600
TabIndex = 4
Top = 2040
Width = 1095
End
Begin VB.CommandButton CommandAdd
Caption = "添 加"
Default = -1 'True
Height = 495
Left = 600
TabIndex = 3
Top = 1320
Width = 1095
End
Begin VB.ListBox List1
Height = 1500
Left = 2040
TabIndex = 2
Top = 1080
Width = 1095
End
Begin VB.TextBox TextXM
Height = 375
Left = 600
TabIndex = 1
Top = 600
Width = 1095
End
Begin VB.Label Label2
Height = 375
Left = 2160
TabIndex = 6
Top = 600
Width = 975
End
Begin VB.Label Label3
Caption = "当前人数:"
Height = 375
Left = 2040
TabIndex = 5
Top = 240
Width = 1095
End
Begin VB.Label Label1
Caption = "输入姓名:"
Height = 375
Left = 120
TabIndex = 0
Top = 240
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub CommandAdd_Click() '添加
If TextXM.Text <> "" Then '不添加空数据
List1.AddItem TextXM.Text
Label2.Caption = List1.ListCount '显示当前人数
TextXM.Text = ""
End If
TextXM.SetFocus
End Sub
Private Sub List1_Click()
CommandDelete.Enabled = True '使“删除”按钮可用
End Sub
Private Sub CommandDelete_Click() '删除
I = List1.ListIndex '获得当前所选项目的索引号
List1.RemoveItem I
Label2.Caption = List1.ListCount
CommandDelete.Enabled = False '使“删除”按钮不可用
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?