📄 form0407.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "列表框应用"
ClientHeight = 3735
ClientLeft = 60
ClientTop = 450
ClientWidth = 4860
LinkTopic = "Form1"
ScaleHeight = 3735
ScaleWidth = 4860
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text2
Height = 495
Left = 1920
TabIndex = 11
Top = 720
Width = 1215
End
Begin VB.CommandButton Command4
Caption = "退出"
Height = 495
Left = 3480
TabIndex = 9
Top = 3000
Width = 975
End
Begin VB.TextBox Text3
Height = 495
Left = 1920
TabIndex = 8
Top = 3000
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "全部清除"
Height = 495
Left = 3480
TabIndex = 6
Top = 2280
Width = 975
End
Begin VB.TextBox Text1
Height = 495
Left = 1920
TabIndex = 4
Top = 120
Width = 1215
End
Begin VB.ListBox List1
Height = 960
ItemData = "Form0407.frx":0000
Left = 1920
List = "Form0407.frx":0002
TabIndex = 2
Top = 1440
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "删除"
Height = 495
Left = 3480
TabIndex = 1
Top = 1560
Width = 975
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 495
Left = 3480
TabIndex = 0
Top = 720
Width = 975
End
Begin VB.Label Label4
Caption = "添加列表项"
Height = 495
Left = 600
TabIndex = 10
Top = 720
Width = 1215
End
Begin VB.Label Label3
Caption = "列表项总数:"
Height = 375
Left = 480
TabIndex = 7
Top = 3120
Width = 1335
End
Begin VB.Label Label2
Caption = "列表框内容:"
Height = 375
Left = 600
TabIndex = 5
Top = 1440
Width = 1215
End
Begin VB.Label Label1
Caption = "所选列表项:"
Height = 255
Left = 600
TabIndex = 3
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
Option Explicit
Private Sub Command1_Click()
'添加列表项
List1.AddItem Text2.Text
Text3 = List1.ListCount
End Sub
Private Sub Command2_Click()
'删除列表项
List1.RemoveItem List1.ListIndex
Text3 = List1.ListCount
End Sub
Private Sub Command3_Click()
'全部清除列表项
List1.Clear
Text3 = List1.ListCount
End Sub
Private Sub Command4_Click()
'单击退出按钮
End
End Sub
Private Sub Form_Load()
'装载窗体
With List1
.AddItem "北京市"
.AddItem "上海市"
.AddItem "天津市"
.AddItem "江苏省"
.AddItem "河北省"
.AddItem "山东省"
.AddItem "安徽省"
End With
Text3 = List1.ListCount
End Sub
Private Sub List1_Click()
'单击列表框
Text1 = List1.List(List1.ListIndex)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -