Jump to content

SearchList

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
14 replies to this topic

#1
Egz0N

Egz0N

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,034 posts
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:
[ATTACH]1261[/ATTACH]

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

and than add this code to the button ..

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:

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 ..

[ATTACH]1260[/ATTACH]

Thanks, Egz0N .. :)

Attached Files


Edited by Jordan, 15 January 2009 - 06:44 AM.


#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
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?

theListText = LCase(List1.List(theList))

Why do you use a for loop?
For theList = 0 To List1.ListCount - 1

Why do you compare the text values?
    If theListText = textToSearch Then List1.Text = textToSearch

?? :confused:

#3
mendim.

mendim.

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,393 posts
I Really needed it..
Thank a lot EgzON +rep .

#4
Egz0N

Egz0N

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,034 posts

Quote

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 ..

Quote

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 ..

Quote

How do I remove items from the listbox?


using the code list1.removeitem(index)

Quote

What does this code do?


theListText = LCase(List1.List(theList))


it takes only lowercase words on the list with index "thelist"

Quote

Why do you use a for loop?

For theList = 0 To List1.ListCount - 1


cos "for loop" is more adapted for this searchlist ..


Quote

Why do you compare the text values?

    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 :)

#5
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Perfect! Now I understand! :D +rep

#6
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts
Looked up, looks really good !
One question how did you do it good? :P?
Posted Image

#7
MathX

MathX

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,001 posts
+rock :D. Very nice :D

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


#8
Egz0N

Egz0N

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,034 posts

Jordan said:

Perfect! Now I understand! :D +rep

thanks :)

Turk4n said:

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

lol .. thanks ..

MathXpert said:

+rock :D. Very nice :D

thanks .. :)

#9
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Nice one, +rep.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#10
Egz0N

Egz0N

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,034 posts

Xav said:

Nice one, +rep.

thanks bro .. :)

#11
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
My absolute pleasure. :rolleyes:
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#12
Dren

Dren

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 448 posts
I like it, this gave me an idea for another tutorial, +rep:)