+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: SearchList

  1. #1
    Join Date
    Sep 2008
    Location
    Kosovo
    Posts
    4,032
    Rep Power
    44

    SearchList

    Hello CodeCall members ..
    Today I am going to show you how to make a simple SearchList using VB 6 ..

    Ok .. all you need is a form .. a TextBox .. a button and a ListBox ..

    the SearchList will look like this:
    SearchList-98981695et0.png

    Ok than .. rename the button to "Search" first ..

    and than add this code to the button ..

    Code:
    Dim theList As Long
    Dim textToSearch As String
    Dim theListText As String
    
    textToSearch = LCase(Text1.Text)
    
    For theList = 0 To List1.ListCount - 1
    
        theListText = LCase(List1.List(theList))
    
        If theListText = textToSearch Then List1.Text = textToSearch
    
    Next
    End Sub
    and than after this .. add:

    Code:
    Private Sub Form_Load()
    List1.AddItem "Code"
    List1.AddItem "CodeCall"
    List1.AddItem "Member"
    List1.AddItem "Admin"
    List1.AddItem "Mod"
    End Sub
    this is the list that loads the items to the listbox on Application StartUp ..

    now .. if you search for one the items on the list ..that item will be selected ..

    ...

    and now .. a test ..

    SearchList-73213403ri1.png

    Thanks, Egz0N ..
    Attached Files Attached Files
    Last edited by Jordan; 01-15-2009 at 06:44 AM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: SearchList

    Not bad, it is mostly code so I'm left with a few questions (being a n00b). How does this work? How does the search list know how to find the results? How do I remove items from the listbox? What does this code do?

    Code:
    theListText = LCase(List1.List(theList))
    Why do you use a for loop?
    Code:
    For theList = 0 To List1.ListCount - 1
    Why do you compare the text values?
    Code:
        If theListText = textToSearch Then List1.Text = textToSearch
    ??

  4. #3
    Join Date
    Nov 2008
    Location
    Kosovo.
    Posts
    2,391
    Rep Power
    30

    Re: SearchList

    I Really needed it..
    Thank a lot EgzON +rep .

  5. #4
    Join Date
    Sep 2008
    Location
    Kosovo
    Posts
    4,032
    Rep Power
    44

    Re: SearchList

    How does this work?
    this works using a loop that passes through each item on the listbox and checks if the searched item fits with the found one ..

    How does the search list know how to find the results?
    by checking all the elements of the list one by one if they are the same as the text we typed in the textbox ..

    How do I remove items from the listbox?
    using the code list1.removeitem(index)

    What does this code do?

    Code:
    theListText = LCase(List1.List(theList))
    it takes only lowercase words on the list with index "thelist"

    Why do you use a for loop?
    Code:
    For theList = 0 To List1.ListCount - 1
    cos "for loop" is more adapted for this searchlist ..


    Why do you compare the text values?
    Code:
        If theListText = textToSearch Then List1.Text = textToSearch
    this code is used to check if the current element is the same as the searched words if yes, the searched item will be selected ..


    sry .. i didn't explain this from the beginning but next time i'll explain each of the code what it does ..

    Thanks, Egz0N

  6. #5
    Jordan Guest

    Re: SearchList

    Perfect! Now I understand! +rep

  7. #6
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,852
    Blog Entries
    4
    Rep Power
    49

    Re: SearchList

    Looked up, looks really good !
    One question how did you do it good? ?

  8. #7
    Join Date
    Oct 2008
    Location
    Istog, Kosova
    Posts
    4,001
    Blog Entries
    1
    Rep Power
    40

    Re: SearchList

    +rock . Very nice
    Interested in participating in community events?
    Want to harness your programming skill and turn it into absolute prowess?
    Come join our programming events!

  9. #8
    Join Date
    Sep 2008
    Location
    Kosovo
    Posts
    4,032
    Rep Power
    44

    Re: SearchList

    Quote Originally Posted by Jordan View Post
    Perfect! Now I understand! +rep
    thanks

    Quote Originally Posted by Turk4n View Post
    Looked up, looks really good !
    One question how did you do it good? ?
    lol .. thanks ..

    Quote Originally Posted by MathXpert View Post
    +rock . Very nice
    thanks ..

  10. #9
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: SearchList

    Nice one, +rep.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  11. #10
    Join Date
    Sep 2008
    Location
    Kosovo
    Posts
    4,032
    Rep Power
    44

    Re: SearchList

    Quote Originally Posted by Xav View Post
    Nice one, +rep.
    thanks bro ..

+ Reply to Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts