LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Close one button dialog window

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.

Capture.PNG

 

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 

0 Kudos
Message 1 of 9
(3,620 Views)

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?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 9
(3,610 Views)

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.

Message 3 of 9
(3,605 Views)

@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!!! 😄

0 Kudos
Message 4 of 9
(3,580 Views)

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.

0 Kudos
Message 5 of 9
(3,541 Views)

Hello,

 

It's working when I use the Event Structure, Thank you for your support !

Event_Structure.JPG

0 Kudos
Message 6 of 9
(990 Views)

@Marwen001 wrote:

Hello,

 

It's working when I use the Event Structure, Thank you for your support !

Event_Structure.JPG


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.

0 Kudos
Message 7 of 9
(950 Views)

@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.

0 Kudos
Message 8 of 9
(930 Views)

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!

0 Kudos
Message 9 of 9
(813 Views)