?
Solved

list box find

Posted on 2004-08-17
7
Medium Priority
?
290 Views
Last Modified: 2010-04-17
I have a list box that contains data like this ip,username,computername. Now i need to be able to find an item just by the ip. I tried going record by record and comparing but this takes a while when you have to many entries. Any suggestions? Thanx
0
Comment
Question by:DARKSAGES
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 6

Assisted Solution

by:pillbug22
pillbug22 earned 300 total points
ID: 11823673
If you use an ArrayList to put the items in, then bind the ArrayList to the list box - the ArrayList has sorting and searching features
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 11823941
DARKSAGES,

What language are you working in?  VB6 or .Net?

Idle_Mind
0
 

Author Comment

by:DARKSAGES
ID: 11824268
vb
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Assisted Solution

by:kouroshparsa
kouroshparsa earned 300 total points
ID: 11825026
First of all, "you have too many entries". How many approximately?
If you have less than 500 IP's I suggest:
1-Use another listBox for IP's
OR
2-When you add the data to the list box, if you are adding an IP, add it to the beginning of the list box. Then when you search for the IP, you reach the result faster.
OR
3- Depending on the amount and number of data (if more than 1000 IP's), you may want to sort the IP's in order to use the binary-search.
OR
4- A great idea is: when the user enters the data, as you add them to the listBox, also add the particular IP to a dinamic array. Then if you have less than 1000 IP's you can quickly go through the array...
It all depends on the program's structure. May be  you would describe your application a bit more.
0
 
LVL 7

Assisted Solution

by:jacobhoover
jacobhoover earned 300 total points
ID: 11825411
Several suggestions,

#1 and probably fastest if the IP can be the first item in the list and it is unique you can use.

Dim index as Long
index = SendMessage(hwnd of List Box, LB_FINDSTRING, -1, ByVal the IP address as a string)
listBox.ListIndex = index

#2 you could set the ItemData value to the IP address and scan it, however this would still be a loop

If you want more code or if I'm going where you want, just ask.
0
 
LVL 3

Accepted Solution

by:
Stimphy earned 300 total points
ID: 11827401
Hello,
Why dont you use a listView?  It has searching options built into it without the need for API calls.

Just add a command button and a listView to the form and paste the following code.

Private Sub Command1_Click()
    Dim li As ListItem
    Set li = ListView1.FindItem("1690")
    li.Selected = True
    li.EnsureVisible
End Sub

Private Sub Form_Load()
    ListView1.View = lvwList
    ListView1.HideSelection = False
    Dim cnt As Integer
    For cnt = 1 To 5000
        ListView1.ListItems.Add , , cnt
    Next
End Sub

Regaurds,
Dave
0
 
LVL 23

Assisted Solution

by:gecko_au2003
gecko_au2003 earned 300 total points
ID: 11860370
This might be a stupid suggestion and considering I have only started using visual basic but couldnt you use an ADO control and make an access database to store all ip addys, usernames and computer names in to a database and then once you have retrieved them insert them into a database table then that way you can search through the database table to look for the relevant ip address and then from there bind that to the relvant record number and then you can ascertain there username, computer name, etc.??

I hope this helps, if not then like I said it was only a suggestion.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question