LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to record "item" instead of "value" of a combo box?

Hi,
 
I'm using the combo box where items and values are different.  When probing at the combo box output while system is running, it shows "value" as expected.  However, I want to record the "item" of the combo box and not the "value".  Please help!
 
Ex:
 
Combo box Voltage
Items   
 
thanks,
Anh
0 Kudos
Message 1 of 9
(4,937 Views)

Sorry, accidently sent before finish

Hi,
 
I'm using the combo box where items and values are different.  When probing at the combo box output while system is running, it shows "value" as expected.  However, I want to record the "item" of the combo box and not the "value".  Please help!
 
for example:
Combo box Voltage
Items    Values
800           0
900           1
1000         2
 
 
thanks,
Anh
0 Kudos
Message 2 of 9
(4,935 Views)
Hi Anh,

If you create a property node for the combo box one of the available properties is "Strings and Values [ ] " . This is an of clusters. The cluster is comprised of two items one the label string and the other the value string. You could unbundle the cluster and search this array for the matching "value" and then get the corresponding label.

hope this helps

--Russ
0 Kudos
Message 3 of 9
(4,932 Views)
Sorry second sentence should read " an array of clusters"

--Russ
0 Kudos
Message 4 of 9
(4,929 Views)
Thanks Russ, I've tried to used the unbundle but could not connect to the output of the StringAndValues[].  However, I could write it into an array.  Am I doing it wrong?

thanks,
Anh
0 Kudos
Message 5 of 9
(4,907 Views)
Anh,

It is an array but it is an array of clusters. You need to search through the array for the matching "value" string of your combo box and by unbundling the array elements you will then get the corresponding "label" string. If your values are literally going to be labeled 0, 1, 2 as in your example you can convert the combo value to a decimal then feed it into "index array" and then unbundle that element and get the "label" string. I will attach a vi that show this and a more general method if your values are not so systemically labeled as 0,1,2 etc.

cheers,

--Russ
0 Kudos
Message 6 of 9
(4,892 Views)
Hmm, it works ok now, my bad:(  I need to tie the StringsAndValues[] to and IndexArray, then select an index to send to the Unbundle by Name function.  Since I have many Combo boxes, it tooks a lot of area in Block Diagram to do this for each of them (whining :)). But seriously, is there a shorter way of doing this?

thanks,
Anh
0 Kudos
Message 7 of 9
(4,890 Views)
Anh,

If space is of a concern you could make the search for label a sub vi. As a matter of fact you simply pass the combo box control reference to the sub vi and then it can return the "label" string.  I am assuming there is some reason why you need the values and labels to be different since the default of the combo box is to have them be the same string and no search is necessary at all??

cheers,

--Russ


0 Kudos
Message 8 of 9
(4,883 Views)
The subvi will help in space!  I have to use mapping in the combo box because this combo box is controlling the DAQmx Write which takes in  32-bit unsigned integer as its data.  So when the user select 900mV for example, it will send out a value of 1 to the DAQmx Write which will toggle the appropriate bits to set the system under test to 900mV.

thanks again for your help,
Anh
0 Kudos
Message 9 of 9
(4,880 Views)