LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid input event for numeric control

Need to catch the event when invalid input being through out, customer doesn't like the notify.

 

George Zou
0 Kudos
Message 1 of 8
(3,583 Views)

see the discussion here

0 Kudos
Message 2 of 8
(3,579 Views)

Thanks for the quick reponse.

 

I'm not worry about the min/max.  It's the multiple "." I want to catch.

Whenever it being throught out, I want to popup a error message window.

Customer doesn't like the notify.

 

 

George Zou
0 Kudos
Message 3 of 8
(3,576 Views)

May be I miss the point: for a numeric control, if you set range checking to ignore, and enter 1.2.3 or 1.2... or something like that, the old value is kept and the wrong entry is ignored: why would you like to know about this?

0 Kudos
Message 4 of 8
(3,574 Views)

The concern is that when an invalid input, such as 1..23, being ignored and return to 0, user may not notice, and thought 1.23 is used.

So whenever an invalid input is ignored, popup an error message to notify user.  CVI has a notify, but customer doesn't like it.

 

 

George Zou
0 Kudos
Message 5 of 8
(3,572 Views)

In this case I only have a 'not so elegant' suggestion: use a string control and convert the text to a number... 

Message 6 of 8
(3,571 Views)

It seems CVI notify doesn't work for invalid input, only for out of range.

 

I'm suprised CVI swallow the invalid input silently.

 

 

George Zou
0 Kudos
Message 7 of 8
(3,514 Views)

I haven't had a big problem with this, and I plan to continue to use numeric controls instead of making everything strings, but it does seem strange that CVI doesn't catch this.  I like the automatic range checking options, the programmable increment/decrement buttons, and the ease of use.

 

You can use a quirk in CVI to catch this: if you enter an invalid number like 1.2.3 or 3...14159 or 1-2, CVI triggers EVENT_VAL_CHANGED, but leaves the original number unchanged.  So you can create a case in the callback for the numeric control for EVENT_VAL_CHANGED, and in that case check to see if the value is the same as the previous value.  If it is, assume an invalid input.  EVENT_VAL_CHANGED does not get fired if you just press Enter without changing the value.

 

There are a couple of limitations or drawbacks to this approach.  It doesn't save your invalid entry, so you have to enter the whole thing again instead of just correcting your mistake.  EVENT_VAL_CHANGED also gets fired if you use Delete or Backspace, even if the number you end up with is the same as the previous.  So this approach will flag that as an invalid entry.

 

See the attached example.

0 Kudos
Message 8 of 8
(3,447 Views)