📄 增强列表框功能.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1500
ClientLeft = 60
ClientTop = 345
ClientWidth = 7065
LinkTopic = "Form1"
ScaleHeight = 1500
ScaleWidth = 7065
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 500
Left = 3300
Top = 1320
End
Begin VB.TextBox Text1
Height = 270
Left = 120
TabIndex = 1
Top = 180
Width = 6795
End
Begin VB.ListBox List1
Height = 780
Left = 120
TabIndex = 0
Top = 600
Width = 6795
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim n As Long
Private Sub Form_Load()
Dim FileNum As Long
Dim catalog(200) As String
Dim i As Long
Dim FileName As String
ChDir App.Path
ChDrive App.Path
FileName = "test.txt"
FileNum = FreeFile
Open FileName For Input As #FileNum
Do While Not EOF(FileNum)
Line Input #FileNum, catalog(i)
If catalog(i) <> "" Then
List1.AddItem catalog(i)
End If
i = i + 1
Loop
Close #FileNum
n = 1
End Sub
Private Sub List1_Click()
Timer1.Enabled = True
End Sub
Private Sub List1_DblClick()
Timer1.Enabled = False
Print "Sample"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim KeyWord As String
Dim ListItem As String
Dim Locality As Long
Dim i As Long
If KeyAscii = 13 Then
KeyWord = Trim(Text1.Text)
For i = 0 To List1.ListCount - 1
ListItem = List1.List(i)
Locality = InStr(ListItem, KeyWord)
If Locality <> 0 Then
List1.Selected(i) = True
End If
Next i
End If
End Sub
Private Sub Timer1_Timer()
List1.ListIndex = List1.ListIndex + n
If List1.ListIndex = List1.ListCount - 1 Then n = -1
If List1.ListIndex = 0 Then n = 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -