Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hiii , i have one textbox which contain atleast 1 lakh character and have one listbox which contain 50 thousand lines items , my question is what is the faster way to compair item in listbox with textbox .... i m using ....
VB
dim rohit as string = textbox1.text

for each dd1 as string in database1.items

if rohit.contain (dd1) then
msgbox()
else
msgbox()

 next



but this method is very slow and compair 15 lines textbox 1024 within 15 sec ....
:
textbox data is coming from textfile
&
database data is also coming from textfile

both the data's are store in the form and then i used button
to search weather the textbox character match
with listbox items ....



thanks in advance

Need Urgent Help ...
Deadline is Coming close ....
Posted
Updated 29-Apr-15 23:43pm
v4
Comments
Member 10521418 30-Apr-15 4:43am    
plzzz help me out .... m stuck very badly and my deadline is coming very close plzzz help...
Ralf Meier 30-Apr-15 4:46am    
Perhaps you can submit your complete code and I look if there is something changable inside.
But basicly - I don't know another way to do the work as you decribed it ...
Member 10521418 30-Apr-15 4:49am    
There is always an another way .... this is only code i stucked it is handle by button with this code only....
Member 10521418 30-Apr-15 5:04am    
i have mentioned the code ,plzzz check it out
Member 10521418 30-Apr-15 5:11am    
if the item in listbox arises within first 5000 index then the search for the string is quit quick but when it is in 50 thousand index it take long to search .....

1 solution

For starters, you shouldn't be storing 50,000 items in a ListBox anyway: that kind of quantity is just annoying for the user as they can't look at than many items in a reasonable timescale anyway - so get rid of it, and think of a way to store your text in a List or similar instead, with a summary or extract displayed to the user. You can then start to use hashes to improve your search performance.

If your list of items doesn't contain duplicates, then consider using a Hashset[^] instead - it's search performance is pretty much the same regardless of the number of elements.
 
Share this answer
 
Comments
Member 10521418 30-Apr-15 5:48am    
well the data is not for the users to check and use that was hidden from them as they dont have need of it...
OriginalGriff 30-Apr-15 6:00am    
If you are not displaying something, then **don't use a display control**
They come with a huge amount of "baggage" with slows things down, and uses far more memory than they need to. Display controls are for just that: display!
Member 10521418 30-Apr-15 5:56am    
f the item in listbox arises within first 5000 index then the search for the string is quit quick but when it is in 50 thousand index it take long to search .....
OriginalGriff 30-Apr-15 6:01am    
Stop posting the same irrelevant stuff and look at what I said!
OriginalGriff 30-Apr-15 6:17am    
Then what the heck are you doing playing with strings?
What have you done, converted the files into strings of hex characters?

I think you are trying to run before you can walk: I'm not sure this project is really going to work too well until you have rather more experience under your belt.

I'd strongly suggest that you need to look at simpler tasks that will allow you to learn first, before you tackle a project like this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900