# 50分 求ListView 搜索函数的使用实例,该如何解决

www.MyException.Cn  网友分享于：2013-01-25  浏览：13次
50分 求ListView 搜索函数的使用实例
ListView   搜索函数如下

'   函数名:     SearchListView
'   描述:ListView   搜索函数
'日期:2005.03.05
'**************************************

Option   Explicit
Public   Sub   SearchListView(ListViewX   As   ListView,   SearchString   As   String,   ListViewZ   As   ListView)
On   Error   Resume   Next
Dim   w,   x,   y,   z   As   Integer
Dim   a,   b   As   String
ListViewX.ListItems.Item(1).Selected   =   True
SearchString   =   LCase(SearchString)

Do   Until   ListViewX.SelectedItem.Index   =   ListViewX.ListItems.Count
a   =   LCase(ListViewX.SelectedItem.Text)
z   =   Len(a)
y   =   Len(SearchString)

For   x   =   1   To   z

If   Mid(a,   x,   y)   =   SearchString   Then

If   ListViewX.SelectedItem   =   b   Then
Else
b   =   ListViewX.SelectedItem
End   If
End   If
Next   x
w   =   ListViewX.SelectedItem.Index
w   =   w   +   1
ListViewX.ListItems.Item(w).Selected   =   True
Loop
ListViewX.ListItems.Remove   (ListViewX.ListItems.Count)
End   Sub

------解决方案--------------------

Option Explicit
Public Sub SearchListView(ListViewX As ListView, SearchString As String, ListViewZ As ListView)
On Error Resume Next
Dim w, x, y, z As Integer
Dim a, b As String