Solved

list box find

Posted on 2004-08-17
7
245 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
7 Comments
 
LVL 6

Assisted Solution

by:pillbug22
pillbug22 earned 100 total points
Comment Utility
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 85

Expert Comment

by:Mike Tomlinson
Comment Utility
DARKSAGES,

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

Idle_Mind
0
 

Author Comment

by:DARKSAGES
Comment Utility
vb
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Assisted Solution

by:kouroshparsa
kouroshparsa earned 100 total points
Comment Utility
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 100 total points
Comment Utility
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 100 total points
Comment Utility
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 100 total points
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MaxSpan challenge 9 65
scoresClump  challenge 31 107
scoreUp challenge 14 47
Path of Workbook 3 44
Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
This is an explanation of a simple data model to help parse a JSON feed
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now