473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with List view

Hello.
before I paste my code I will try and explain what I am trying to achieve.
I have loaded a txt file which contains 26,000 items into a listview
I want to be able to enter some text into a text box and when I press a
command button it
Removes all items from the listview that DOES NOT match what I have entered
in the text box.
Although the code below works, it is extremely SLOW.
can anyone help me improve this, (example code would be great)

Regards
Ian
Private Sub cmdok_Click()
Dim SearchItem As String
SearchItem = LCase$(Trim$(txtfind)) 'txtfind is a textbox
Dim i As Long
Me.MousePointer = vbHourglass

For i = listview1.ListItems.Count - 1 To 0 Step -1
If i = 0 Then GoTo done
If InStr(listview1.ListItems(i), SearchItem) > 0 Then

Else
With listview1.ListItems
.Remove (i)
End With
End If

Next
done:
Me.MousePointer = vbDefault

End Sub
Jul 17 '05 #1
4 5560
Don
On Mon, 21 Jul 2003 19:30:37 +0100, "whirl" <wh***@whirl.org.uk> wrote:
Hello.
before I paste my code I will try and explain what I am trying to achieve.
I have loaded a txt file which contains 26,000 items into a listview
I want to be able to enter some text into a text box and when I press a
command button it
Removes all items from the listview that DOES NOT match what I have entered
in the text box.
Although the code below works, it is extremely SLOW.
can anyone help me improve this, (example code would be great)

Regards
Ian
Private Sub cmdok_Click()
Dim SearchItem As String
SearchItem = LCase$(Trim$(txtfind)) 'txtfind is a textbox
Dim i As Long
Me.MousePointer = vbHourglass
Something to try.. Not really sure how it will affect the display
listview1.visible = false 'then set it visilble=true on exit
If that is flaky then you might want to try the LockWindowUpdate API
Declare Function LockWindowUpdate Lib "user32" Alias _
"LockWindowUpdate" (ByVal hwndLock As Long) As Long
And call it like
LockWindowUpdate me.hwnd
and on exit
LockWindowUpdate 0&

Control Refreshs are a bugger... LOL
For i = listview1.ListItems.Count - 1 To 0 Step -1
If i = 0 Then GoTo done
If InStr(listview1.ListItems(i), SearchItem) > 0 Then

Else
With listview1.ListItems
.Remove (i)
End With
End If

Next
done:
Me.MousePointer = vbDefault

End Sub


Have a good day...

Don
Jul 17 '05 #2
hello, would copying the matching text to another listbox work, I just read
your post and modified something I have been working on to solve issues for
others. if not let me know and I will modify it to just delete from the
listbox in question.
"whirl" <wh***@whirl.org.uk> wrote in message
news:cp*******************@news-binary.blueyonder.co.uk...
Hello.
before I paste my code I will try and explain what I am trying to achieve.
I have loaded a txt file which contains 26,000 items into a listview
I want to be able to enter some text into a text box and when I press a
command button it
Removes all items from the listview that DOES NOT match what I have entered in the text box.
Although the code below works, it is extremely SLOW.
can anyone help me improve this, (example code would be great)

Regards
Ian
Private Sub cmdok_Click()
Dim SearchItem As String
SearchItem = LCase$(Trim$(txtfind)) 'txtfind is a textbox
Dim i As Long
Me.MousePointer = vbHourglass

For i = listview1.ListItems.Count - 1 To 0 Step -1
If i = 0 Then GoTo done
If InStr(listview1.ListItems(i), SearchItem) > 0 Then

Else
With listview1.ListItems
.Remove (i)
End With
End If

Next
done:
Me.MousePointer = vbDefault

End Sub

Jul 17 '05 #3
Posted and emailed:
"whirl" <wh***@whirl.org.uk> wrote:
Hello.
before I paste my code I will try and explain what I am trying to achieve.
I have loaded a txt file which contains 26,000 items into a listview
I want to be able to enter some text into a text box and when I press a
command button it
Removes all items from the listview that DOES NOT match what I have entered
in the text box.
Although the code below works, it is extremely SLOW.
can anyone help me improve this, (example code would be great)

Regards
Ian

[code snipped]

In a related competition for speed in comp.lang.basic.visual.misc Dag
Sunde provided an elegant and very fast solution by using the text
file ODBC driver and an SQL SELECT statement. In your case you can use
the same code to (re)populate the listview just by changing the SELECT
statement. The follow ups provide additional information about setting
up the ODBC driver. Here is the link to his post
http://www.google.com.au/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&frame=right&rnum=31&thl=1135047719,1134966979,11 34770359,1134751242,1134739727,1134737281,11346581 65,1134622808,1134521208,1134510182,1134484638,113 4439555&seekm=QXYL9.3785%24ZL2.337240%40juliett.da x.net#link32

Jul 17 '05 #4
Many thanks for all those who gave me the advice i was looking for

Cheers
"whirl" <wh***@whirl.org.uk> wrote in message
news:cp*******************@news-binary.blueyonder.co.uk...
Hello.
before I paste my code I will try and explain what I am trying to achieve.
I have loaded a txt file which contains 26,000 items into a listview
I want to be able to enter some text into a text box and when I press a
command button it
Removes all items from the listview that DOES NOT match what I have entered in the text box.
Although the code below works, it is extremely SLOW.
can anyone help me improve this, (example code would be great)

Regards
Ian
Private Sub cmdok_Click()
Dim SearchItem As String
SearchItem = LCase$(Trim$(txtfind)) 'txtfind is a textbox
Dim i As Long
Me.MousePointer = vbHourglass

For i = listview1.ListItems.Count - 1 To 0 Step -1
If i = 0 Then GoTo done
If InStr(listview1.ListItems(i), SearchItem) > 0 Then

Else
With listview1.ListItems
.Remove (i)
End With
End If

Next
done:
Me.MousePointer = vbDefault

End Sub

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Patrick De Ridder | last post by:
Below a rather simplistic example of a list view routine. Say I want to have "over" appearing in red on the display, how would I do that? Many thanks, Patrick. patrick.de.ridder@hetnet.nl...
1
by: Muhammad Aftab Alam | last post by:
Hi All, I need to know how can I make a list contorl like of windows explorer. From windows explorer view I mean when we open My Computer a list view is shown and the headers are shown as follows...
1
by: ksadek | last post by:
I have a list view that displays messages from a server over an Ip connection. I have set the list view to include a scrolling function, however, I can not figure out how to scroll to the last...
11
by: Brian Henry | last post by:
Well here is the problem, I have a data set with about 9,000 to 20,000 people in it in the data table "people"... I am then reading it into a list view one at a time row by row... adding each...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
3
by: Brian Henry | last post by:
So what is the easiest way to do this? I have one list view with a list of items (in detail view and with about 20 sub items) and a second list view that will take the items they drag from the...
2
by: baling | last post by:
Hi, everybody. I have some problem in my program. In this case i have a list view. In this list view there are some record. Now i want to save that record into database, but i don't know how....
0
by: lball | last post by:
I am using a ListView and I need to add an icon to a row. Totally lost and know that this should be really simple. Any help would be great!. Thanks lb
4
by: AjGrace | last post by:
Guys.. I know that this is so easy but I can't figure it out why List View Display an False text instead of the Data in my Database my Code is this Private Sub Form_Load() ...
2
by: Mohit | last post by:
Hi all, I am working on a windows application with a list view on a form. Now I wanted to show hand cursor when mouse is over list view item and default(arrow) cursor at other places. List...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.