📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Option Explicit
Public Const KEY_BACK = &H8
Public Const KEY_DELETE = &H2E
Public Const KEY_CLEAR = &HC
Public Const TEXTBOX_FOCUS = 1
Public Const LISTBOX_FOCUS = 2
Public miCtrlFocus As Integer
Public miNumKeys As Integer
Public mfScrolling As Integer
Public mfKeepKey As Integer
Function SearchListBox(ByVal szSearchText As String, lbScroll As ListBox, iListIndex As Integer) As Integer
Const FOUND = 0
Const LT = -1
Const GT = 1
Dim iListStart As Integer
Dim iListCount As Integer
Dim iTxtLen As Integer
Dim szListText As String
Dim vCompResult
Dim fFound As Integer
Dim fDone As Integer
fFound = False
iTxtLen = Len(szSearchText)
If iTxtLen > 0 And lbScroll.ListCount > 0 Then
iListStart = lbScroll.ListIndex
If iListStart = -1 Then iListStart = 0
iListIndex = iListStart
iListCount = lbScroll.ListCount
szListText = Left(lbScroll.List(iListStart), iTxtLen)
fFound = CInt(StrComp(szSearchText, szListText, 1))
If fFound <> FOUND Then
fDone = False
If (fFound = LT) Then
iListIndex = 0
fFound = False
Else
iListIndex = iListIndex + 1
End If
Do While (iListIndex <= iListCount) And Not fDone
szListText = Left(lbScroll.List(iListIndex), iTxtLen)
vCompResult = StrComp(szSearchText, szListText, 1)
If IsNull(vCompResult) Then
iListIndex = -1
Exit Do
End If
fFound = (CInt(vCompResult) = FOUND)
fDone = fFound Or (CInt(vCompResult) = -1)
If Not fDone Then
iListIndex = iListIndex + 1
End If
Loop
If Not fFound Then
iListIndex = -1
End If
End If
End If
SearchListBox = fFound
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -