[Gambas-user] Filtering listbox list

Gianluigi bagonergi at gmail.com
Sun Mar 11 22:38:06 CET 2018


I forgot, in the loop 'i' and 'l'' have the same value.

Regards
Gianluigi

2018-03-11 22:25 GMT+01:00 Gianluigi <bagonergi at gmail.com>:

> If you use 'Like TextBox4.Text & "*"' you will get the textbox text plus
> zero or n characters.
> If you want to find the characters written in textbox even in the middle
> of the sentences then you have to write 'Like "*" & TextBox4.Text & "*"'
>
> Regards
> Gianluigi
>
> 2018-03-11 22:03 GMT+01:00 Shannon Kuchler <shannon at inflecto.org>:
>
>> 
>>
>> This code works
>>
>>
>> Public Sub TextBox4_KeyRelease()
>>
>> Dim i As Integer
>> Dim l As Integer
>> i = (-1)
>>
>> ListBox6.Clear
>>
>> If TextBox4.Text = "" Then ListBox6.List = ListBox1.List
>> If TextBox4.Text <= " " Then Return ' not searchable
>> For l = 0 To ListBox1.List.Max
>> Inc i
>> If ListBox1[i].Text Like TextBox4.Text & "*" Then ' found another
>> ListBox6.Add(ListBox1[i].Text)
>> Endif
>> Next
>> end
>>
>>
>> I could not get it to work with out the "Inc i" perhaps I'm missing
>> something there. Before it wasn't catching listbox1.index(0)  so I had to
>> add "i = (-1)"
>>
>> However it still need something because it only 1/2 works
>>
>>
>> for instance this is the data in listbox1
>>
>>
>> The Dying Lands
>> Bad Company
>> Valmod Expansion Pack
>> Valmod Overhaul Pack
>> Darkness Falls (BBP)
>> Starvation
>> War Of The Walkers 5.2 (BBP)
>>
>>
>> if I type "v" in textbox4 I get this output to listbox6 which I expected
>>
>>
>> Valmod Expansion Pack
>> Valmod Overhaul Pack
>>
>>
>> However if I type "t" in textbox4 I get this output to listbox6
>>
>>
>> The Dying Lands
>>
>>
>> I expected 't" to give me everything that had a 't' like this
>>
>>
>> The Dying Lands
>>
>> Starvation
>>
>> War Of The Walkers 5.2 (BBP)
>>
>>
>>
>>
>>
>>
>>
>> Good advice on using ListBox.List.Max.
>>
>> I have found the KeyRelease event to be more reliable in regards to having access to the actual, current keystroke value.
>>
>> And, instead of looping through List, I personally would simply use ListBox.Find.
>>
>>
>> --
>> Lee
>>
>> On 03/11/2018 09:37 AM, Gianluigi wrote:
>> > Maybe you could use the KeyPress event with "If Key.Code = Key.Return Then ...",
>> > "Inc i" is useless and you should use ListBox1.List.Max (or ListBox1.count -1) instead of ListBox1.Count to avoid the 'out of
>> > bound' error.
>> >
>> > Regards
>> > Gianluigi
>> >
>> > 2018-03-11 10:33 GMT+01:00 Shannon Kuchler <shannon at inflecto.org <mailto:shannon at inflecto.org>>:
>> >
>> >     __
>> >
>> >     
>> >
>> >         -I think I figured it out
>> >
>> >
>> >         Public Sub TextBox4_KeyRelease()
>> >         Dim i As Integer
>> >         Dim l As Integer
>> >
>> >         ListBox6.Clear
>> >
>> >
>> >               If TextBox4.text > "z" Or TextBox4.text < " " Then Return
>> >               For l = 0 To ListBox1.Count
>> >                 Inc i
>> >                   If ListBox1[i].Text Like TextBox4.Text & "*" Then ' found another
>> >                   ListBox6.Add(ListBox1[i].Text)
>> >               Endif
>> >               Next
>> >
>> >         End
>> >
>> >
>> >
>>
>> --------------------------------------------------
>>
>> This is the Gambas Mailing List:
>> https://lists.gambas-basic.org/listinfo/user
>>
>> Search the list:
>> https://lists.gambas-basic.org/cgi-bin/search.cgi
>>
>> Hosted by https://www.hostsharing.net
>>
>>
>>
>> --------------------------------------------------
>>
>> This is the Gambas Mailing List:
>> https://lists.gambas-basic.org/listinfo/user
>>
>> Search the list:
>> https://lists.gambas-basic.org/cgi-bin/search.cgi
>>
>> Hosted by https://www.hostsharing.net
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180311/2ccb834d/attachment-0001.html>


More information about the User mailing list