Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contents of a listbox

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
0
16
AU
I want to find out if a particular phrase is already in a listbox.

I've tried
'Test'$thisform.list1
but I get an error.
What would be the correct way to do this?

GenDev
 
From the help:

help said:
$ operator
Returns True (.T.) if a character expression is contained in a

thisform.list1 is the listbox, it's an object, more precisely a conrol and more precisely a listbox. But neither a string expression nor the list of string expressions it displays, those are in thisform.list1.listitems or thisform.list1.list.

To find something in a list of data, usually in a workarea, not in a control proerty or array, the usual suspects are LOCATE/SEEK, ideally accelerated by an index. ASCAN is a function that can find something in an array. Unfortunately the two array properties of the listbox, namely list and listitem, are arrays, but can't be used with array functions. It's only documented for the list property of the listbox:

help said:
You cannot use array functions with the List property. However, if you set the RowSourceType property to 5 (Array) and set the RowSource property to the array of values to be contained in the list, you can use array functions on the array specified in the RowSource property.

And theere you have an inspiration of what to do. You want to find if something is listed, well, then search the data that feeds the listbox, not the listbox itself. So search in the workarea or whatever is the source of the data the listbox displays. You tell nothing baout how your listbox is fed with data,

Get real, you can't expect an answer with as little as you tell about this. It is really straight forward that you tell about the data that feeds this listbox to get the code you need to search that data list, whatever it is.

Chriss
 
The Value property gives you the value of the currently selected item. If you want to know if a given item is present in the listbox (not necessarily the selected item), use the List property. This is an array, which you can search or scan just like any other array.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike said:
just like any other array.
Unfortunately not. Even though both list and listitem are documented to be character string arrays of the items displayed in listbox or combobobx, none of them allow usage of ASCAN on them, try it yourself.

Chriss
 
Thanks Chriss amd Mike

Your detailed answers to my sometimes clumsy questions inspire me to continue with my reimagined project.
In this instance I have found another way to check whether Exif information is available in an image file.

GenDev
 
This question wasn't at all about Exif informations. Nevermind, if you're done with the listbox. Otherwise it would help if you'd answer the question about the data origin of the list you display, because that's where you can search far easier than in the listbox itself.

Chriss
 
Chriss,
I was trying to find out if an image had Exif information which would be listed in the list control. I have found a better way to do it.

Thankyou

GenDev
 
Okay, but reread your first post in this thread, you didn't tell anything about Exif, so can you understand the confusion you cause?

I get from this you're currently without problems and theres no need for continuation, okay.

But next time you post a question, please bear in mind we only know what you post. You had an older thread184-1829644 about the Exif and it would be more conclusive to tell that you're done with that problem there, not in this thread. We had no idea, so far, that you wanted to list Exif informations. We are not in your mind, sorry. You cannot only go back to your last thread, you can go back to the appropriate thread and make your feedback there. In the tab "My Stuff" in the top right of the forum you find "Your Threads" besides other points.

Chriss
 
Thanks Chriss,

Point taken - no intention to confuse - sorry!
 
It would be great, if you also apply this to your thread184-1829644, thank you.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top