Page 1 of 1

SearchString Issue

PostPosted: Tue Nov 28, 2017 12:31 pm
by Dudus
Hi all,

will you able to help me in this case?

I have a ListBox3 wich conatins this lines:
Car Dog House John
Car Dog House Gregor
Car Dog House Thomas

and i would like to show the result in a[dispaly] variable if pick the name of the person from a combobox1, I try to do somethig like this but it wont work:

SetVar "[display]" ""
ListBoxSize "ListBox3" "[Count]"
Loop "1" "[Count]" "[N]"
ListBoxGetItem "[ListBox3]" "[N]" "[Item]"
SearchStr "[combobox1]" "[Item]" "[Pos]" ""
If "[Pos]" "=" "1"
SetVar "[display]" "[display][item][#13]"
Endif
EndLoop

Where is the problem? Because now there is 0 result.
Thank you!
D

Re: SearchString Issue

PostPosted: Tue Nov 28, 2017 2:56 pm
by Gaev
Dudus:

What are the values in [combobox1] ?

a) If the values are an exact match e.g. ...

Car Dog House John
Car Dog House Gregor
Car Dog House Thomas

... then the code should work ... you can try this code and post the results of the AlertBox commands ...
Code: Select all
SetVar "[display]" ""
ListBoxSize "ListBox3" "[Count]"
AlertBox "Trace1" "combobox1=[combobox1],Count=[Count]"

Loop "1" "[Count]" "[N]"
   ListBoxGetItem "[ListBox3]" "[N]" "[Item]"
   SearchStr "[combobox1]" "[Item]" "[Pos]" ""
   If "[Pos]" "=" "1"
      SetVar "[display]" "[display][item][#13]"
   Endif
   AlertBox "Trace2" "N=[N], Item=[Item], Pos=[Pos]" 
EndLoop


b) However, if the values are something like ...

Dog
House
Thomas

... then you need to change ...
Code: Select all
If "[Pos]" "=" "1"

... to ...
Code: Select all
If "[Pos]" ">" "0"

... as you need to catch a match in any position other than zero.

Re: SearchString Issue

PostPosted: Wed Nov 29, 2017 1:28 am
by Dudus
Thank you Gave, works perfect! :)

Dududs!