新建From1(窗体),新建Command1(按钮CommandButton),List1(ListBox)代码:
Private strKey$
Private Sub Command1_Click()
Dim lenKey&
strKey = LCase(InputBox("请输入开头的关键词", "输入", strKey))
lenKey = Len(strKey)
'MsgBox "[" & strKey & "]", vbInformation, "提示"
'MsgBox strKey = "" '如果点击【取消】,会显示True
For i = 0 To List1.ListCount - 1
If Left(List1.List(i), lenKey) = strKey Then
List1.Selected(i) = True
Exit For
End If
Next
End Sub
Private Sub Form_Load()
Dim i&
List1.Clear
List1.Visible = False
For i = 0 To 99
List1.AddItem i
Next
List1.Visible = True
End Sub