Jump to content

adding items to combo box


Recommended Posts

Posted

I have a program where I want to write specific code to a device. When the user selects an item from the combo box, the value correlated to that value will be implemented into the code to write to the device. The values are written normally and I am able to convert it to hexadecimal and then put it in the code to write. My issue is that I also have constant hex values that are unique to each item in the combo box. How would I be able to write those values in so that when the user selects the item it also includes those constants?

Posted (edited)

If you're familiar with Property Nodes, you can use the "Strings and Values []" property for access to both the "Items" and "Values" defined in the combo box.  

Additionally, you can use the "Text.Text" property to get the displayed text (i.e. "Items"), while the value will always be that from the "Values" defined.

image.png.3827b936ad813e911b96eaa04e3e5207.png

image.png.8603a7224467ee67881eb2d66b54a468.png

Edited by Bryan
Posted

awesome. Do you know if there is a way or if its even possible to have a combobox2 where the item selected in combo box one can lead into combo box 2 and I can then implement a new set of values for combo box 2. So essentially combo box 1 and combo box 2 have the same items but the values in combo box 1 are going to be different than in combo box 2. 

Posted

Sure, you could read the "Text.Text" property from ComboBox1 and write it to a "Text.Text" property for ComboBox2.

The caveats would be that your "Items" would have to be named exactly the same, and that you'd have to pay attention to the order of execution.  Best way to force order of exec is using property nodes even for the values.  

Others may have better approaches than I can suggest, but I've never had to do this before, so I'm mocking up quick examples for you.  Below is an example where I use lowercase values for the 2nd combo box.

 

image.png.06dda7efcee22b32749a94c7cdbd8e88.png

Posted

 

Awesome, I will give this a try. Do you know why it is weird in labview with the displays, specifically with a combo box. I want to input hex values for each item. I put the hex value in the combo box. I attach to a string to see what the value is and if in normal it displays, but if i put hex display it gives me a completely different value.

 

Posted

Hex display shows each character of your string as two alpha numeric values. For example, if I wanted to show "My string" as hex it would show "4d7920737472696e67" where 4d was the M, 79 was the y. It's useful for undisplayable characters and things like that

Posted

If i chose to put my combo box inside of a sub vi it gives me a combobox in and a combobox refnum. What are they? 

 

Will labview allow me to transfer over the combo box I created to another VI?

Posted

Property nodes, such as the linked ones that I have shown in my screenshots above, are linked to the controls/indicators within that particular VI/scope, which is what I thought you were wanting to do.  I didn't know that you were wanting to involve moving control and manipulation of them into subVIs.

In different VI (i.e. subVI), you're in a completely different scope, and the control reference(s) will have to be passed to that new VI from the calling VI(s).  LabVIEW tried to do that for you automatically, and you'll have to create references for the control(s) that you want to handle in your subVI.  This can begin to get messy if you're new to using (unlinked) property/invoke nodes.  I recommend spending some time learning about them before going too much further in your coding.

Screenshots of your code will help us provide better assistance, but right now I'm not 100% sure exactly what you're trying to accomplish as the context of the original post seems to be evolving.

Posted

After messing around with labview I was able to just change the reference to the combo box I had created. So I had made a subvi and when I moved it to another VI it didn't have the indicators so I had to include them to fix my issue as well

Posted (edited)

My one final question, How can I convert a hex value to a decimal value? I have a hex string, 1 byte and I keep getting zero no matter what I try for the decimal value 

Edited by epiz
Posted

Can you give us an example of how you want to convert? For example if you had 1 byte: "A", you could convert that to 10 (a number), you could convert that to "10" (a string), or you could even convert that to 65 (the numeric value of the "A" character)

Posted

I have this code for example  1606 1015 24. I know that when I split up each byte, 16  06  10  15  24, I can convert each of these hex values individually to decimal form to get the year, month, day, hour and minute. I have plugged these values in to a converter online and it gives me the values im supposed to get. So for example the 16 in my hex is supposed to turn out a 22 in decimal form. Is this a numeric value or a number, that I dont know. But what I do know is I can't seem to convert it how I want. If that makes sense

Posted

Is the 1606 1015 24 the hex values that would be shown in a string control/indicator when displayed in "Hex Display" mode (in "\ Codes" display it would be "\16\06\10\15$")?  If so, see below:

image.png.b85b0534ebd22bb2713be8f80c538c7a.png

Posted
14 hours ago, Bryan said:

Is the 1606 1015 24 the hex values that would be shown in a string control/indicator when displayed in "Hex Display" mode (in "\ Codes" display it would be "\16\06\10\15$")?  If so, see below:

image.png.b85b0534ebd22bb2713be8f80c538c7a.png

 

You need to preserve the width (2chars per byte) otherwise your concatenated is incorrect (you have 4 1/2 bytes represented instead of 5 because of the 0x06 - see also the guy that wanted to insert 0's). This is a common "bug" that occurs in drivers.

Posted (edited)
On 7/1/2023 at 4:50 AM, ShaunR said:

 

You need to preserve the width (2chars per byte) otherwise your concatenated is incorrect (you have 4 1/2 bytes represented instead of 5 because of the 0x06 - see also the guy that wanted to insert 0's). This is a common "bug" that occurs in drivers.

I had meant to put that in there and had forgotten (I was in a rush).  Thanks for catching that.

image.png.373ab41670f47569872cd0c12891f9ca.png

Edited by Bryan

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.