LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

determining array index

In one of my VIs, I have an array of strings (login names) that feed a listbox.  The user is supposed to select one of the names in the list, then that name is used to do some other stuff.  Actually, the index of the name chosen is what I need.  I know how to get (from a Property Node) the Value of the selection, but I don't see a property that tells me what the index is of the selected item.  Does this property exist, or do I need to feed the string into a search routine?
0 Kudos
Message 1 of 8
(2,996 Views)
For a listbox the value of the terminal is the index.
0 Kudos
Message 2 of 8
(2,995 Views)
Sorry, it's a combo box.
0 Kudos
Message 3 of 8
(2,987 Views)
That's different.

A combobox's datatype is a string, so if you want the index you have to search the 1D array. Note that you do not need to use the "Value" property node. The terminal is the value.



You could also try a menu ring instead.


Message Edited by smercurio_fc on 07-02-2008 09:43 AM
0 Kudos
Message 4 of 8
(2,985 Views)
Just a heads up: if you are using the method smercurio_fc shows above, the index may not be correct if there are duplicate values in the combo box.  The index will always be the value of the first entry in the combo box.  I got caught on this a while back....
0 Kudos
Message 5 of 8
(2,913 Views)
Why would you have a combobox with duplicate values? Besides, a combobox doesn't allow you to have duplicate items.

EDIT: That is assuming that you're entering the items using the Properties dialog box. If you set the items programmatically, then you can have duplicate items. (Still don't know why you would want to do that. How is the user supposed to know which one to pick?)


Message Edited by smercurio_fc on 07-21-2008 01:59 PM
0 Kudos
Message 6 of 8
(2,908 Views)
Yes, I was populating programmatically from a db and this problem came up for me when my user loaded duplicate values into their database and so I had to change my code... 

I'm just posting this so that people are aware of the possibility.
0 Kudos
Message 7 of 8
(2,897 Views)
SELECT DISTINCT column name(s) FROM table_name ... Smiley Happy
0 Kudos
Message 8 of 8
(2,892 Views)