欢迎光临:
  
  非常感谢您光临枕善居。本站是一个免费的基于VB,VB.NET源代码交流的平台,为大家提供优质的专业的源代码,如果您有需要,本站可以帮助在业余时间里给您寻找代码。当然,如果您有好的代码也可以在本站发布,共享给大家。
专业VB和.NET源码、编程开发教程、图标资源、USB电脑遥控器、智能家电控制开关....更多东东请进入我的淘宝小店--->
VB及.NET新源码2011(3DVD,控件+资源) 智能多路控制(串口编程开关) 带源码!


05-03
06

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.Add , , " "
    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
                    ListViewZ.ListItems.Add , , ListViewX.SelectedItem
                    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


相关日志:
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
评论: 6 | 引用: 0 | 查看次数: 6914

回复回复ahuatian2008 [2008-01-27 15:25:44 |  | del]
谢谢分享!!
回复回复99175776 [2007-11-20 13:59:25 |  | del]
Listview里不是有FindItem方法吗?你这个比它快吗?
回复回复cssshk [2006-09-29 10:52:20 |  | del]
请问怎样使用这个函数,能举一个示例吗?谢谢阿
回复回复gaoqi9902 [2006-04-03 17:03:10 |  | del]
谢谢
回复回复sxycgxj [2005-03-10 10:26:32 |  | del]
是搜索List框内的全部内容吧,不错
回复回复Begin2008 [2005-03-06 17:52:21 |  | del]
[smile] 此函数非常有用,谢谢楼主
发表评论
您没有权限发表评论!