epiz Posted June 27, 2023 Report Share Posted June 27, 2023 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? Quote Link to comment
Bryan Posted June 28, 2023 Report Share Posted June 28, 2023 (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. Edited June 28, 2023 by Bryan Quote Link to comment
epiz Posted June 28, 2023 Author Report Share Posted June 28, 2023 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. Quote Link to comment
Bryan Posted June 28, 2023 Report Share Posted June 28, 2023 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. Quote Link to comment
epiz Posted June 29, 2023 Author Report Share Posted June 29, 2023 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. Quote Link to comment
infinitenothing Posted June 29, 2023 Report Share Posted June 29, 2023 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 Quote Link to comment
epiz Posted June 29, 2023 Author Report Share Posted June 29, 2023 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? Quote Link to comment
Bryan Posted June 29, 2023 Report Share Posted June 29, 2023 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. Quote Link to comment
epiz Posted June 30, 2023 Author Report Share Posted June 30, 2023 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 Quote Link to comment
epiz Posted June 30, 2023 Author Report Share Posted June 30, 2023 Thank you Bryan, your help was able to get me through a very difficult obstacle in my code Quote Link to comment
epiz Posted June 30, 2023 Author Report Share Posted June 30, 2023 (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 June 30, 2023 by epiz Quote Link to comment
infinitenothing Posted June 30, 2023 Report Share Posted June 30, 2023 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) Quote Link to comment
epiz Posted June 30, 2023 Author Report Share Posted June 30, 2023 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 Quote Link to comment
Bryan Posted June 30, 2023 Report Share Posted June 30, 2023 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: Quote Link to comment
epiz Posted June 30, 2023 Author Report Share Posted June 30, 2023 yes, I am going to try this out thank you so much Quote Link to comment
ShaunR Posted July 1, 2023 Report Share Posted July 1, 2023 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: 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. Quote Link to comment
Bryan Posted July 3, 2023 Report Share Posted July 3, 2023 (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. Edited July 3, 2023 by Bryan Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.