×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Contents of a listbox

Contents of a listbox

Contents of a listbox

(OP)
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

RE: Contents of a listbox

From the help:

Quote (help)

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

Quote (help)

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

RE: Contents of a listbox

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

RE: Contents of a listbox

Quote (Mike)

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

RE: Contents of a listbox

(OP)
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

RE: Contents of a listbox

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

RE: Contents of a listbox

(OP)
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

RE: Contents of a listbox

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: accessing EXIF information in a jpg image 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

RE: Contents of a listbox

(OP)
Thanks Chriss,

Point taken - no intention to confuse - sorry!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close