08-07-2018 10:10 AM
Hello Community,
I want to display a message to make the user enter a positive value, so I used one button dialog (OK button) as in the screenshot below.
The issue is that each time the dialog window is open, it does not close when i press the Ok button. so I'm obliged to close all Labview application.
I want when the user enters a negative value or value =0, the dialog window opens, the user presses Ok and corrects the value!
Please how can I do such a task
Thank you so much
08-07-2018 10:19 AM
The simple code you published must work, unless the mouse is disabled some way, so there must be something else wrong. Can you attach a more complete example?
08-07-2018 10:26 AM
Try using an Event Structure to handle a Value Change event. There should be some good examples in Help -> Find Examples.
You didn't upload all of your code, but I think your problem is that you check to see if the value =0, and if so, open a popup. When you click OK, it immediately checks again, and since there hasn't been any time for the user to change the setting, the popup opens again.
Your dialog IS going away each time you click the button- your problem is that you're getting an infinite number of dialogs, as your code doesn't ever give the user time to make a change.
Create an event structure and detect when the value changes. If val=0, call popup, and set the control to either the previous value or some safe value (like 1 or something). Basically, ignore the user's input.
Then again: if you NEVER need this value to be able to go below 0, just right click the control, select Data Entry, uncheck "Use Default Limits", set the Minimum to 1, and set Response... to Coerce. Then if the user inputs a value like -4, it'll reset automatically to 1. You won't get a popup this way, and it always coerces low values to 1, but it might do for your application.
08-07-2018 11:21 AM - edited 08-07-2018 11:22 AM
@Student_LV wrote:
I want to display a message to make the user enter a positive value, so I used one button dialog (OK button) as in the screenshot below.
This is just a code fragment, overusing local variables at the same time. You need to attach the entire VI that demonstrates the problem. Is this inside a loop? If it is, it will of course pop the dialog over and over until the condition changes. Where does the user enter the positive number? Where is the value of the positive number in that picture? What is in the other case of the case structure? What is the datatype of "Min 1"? Can the number also be negative? Is there a reason your wires go in all directions?
If you want to restrict the range of number that can be entered, use the "right-click...data entry" option and restrict the input to a desired range. No code or dialogs needed!!! 😄
08-08-2018 12:20 PM - edited 08-08-2018 12:21 PM
I'm not a fan of express VIs, but there is one made for this type of thing called Prompt User, it is on the Dialog and User Interface palette. There you can have various inputs you ask the user to enter like a number. It is easy to use but you have much more flexibility with a custom made VI using the event structure.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-02-2023 06:03 AM
Hello,
It's working when I use the Event Structure, Thank you for your support !
06-02-2023 01:51 PM
@Marwen001 wrote:
Hello,
It's working when I use the Event Structure, Thank you for your support !
Are you the same users as Student_LV ?
This is just silly! All you need to do is change the data entry property of the control and set the minimum allowed to a realistic value, assuming (as described in your first post (!), you want to exclude zero and lower, not just zero).
As has been already said, pictures are not useful, so please attach your VI instead. You don't need a wait if you have an event structure. Your newval will always be identical to the control value, so why use an additional indicator? Seems redundant! Why do you even need to read from the event data node if the control is right there? Why is it now a floating point value, while the original post had integers.
06-02-2023 04:58 PM
@Hooovahh wrote:
I'm not a fan of express VIs, but there is one made for this type of thing called Prompt User, it is on the Dialog and User Interface palette. There you can have various inputs you ask the user to enter like a number. It is easy to use but you have much more flexibility with a custom made VI using the event structure.
Maybe I should work on fixing up my Universal Dialog Box express VI.
I'll think about it.
But now I'm going to paint a flower.
06-17-2023 06:21 PM - edited 06-17-2023 06:25 PM
I'm not. I am a new member, I just created this VI example to have a solution to continue program execution when pressing the OK button a windows dialog.
Thanks for the helpful advice!