程序代码如下:
Private Sub Command1_Click()
Dim Sname As String, Skey As String ‘Sname 保存姓名,Skey保存关键字
Dim i As Integer, j As Integer, n As Integer ‘n关键字的长度
Skey = Text1.Text
n = Len(Skey)
List2.Clear
For i = 1 To List1.ListCount ‘ListCount是列表框中项目的个数
Sname = List1.List(i - 1) ‘将List1中的第i-1项赋值给Sname
For j = 1 To ①
If Skey = ② Then
List2.AddItem Sname
Exit For
End If
Next j
Next i
If ③ = 0 Then List2.AddItem "没有找到带<" & Skey & ">的名字。"
End Sub