LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string control

Hi all:

 

How can I determine that   STRING CONTROL can type only numeric +letter + caps lock letter + under score + dot , and not accept typing these characters   !, @,#,$, %, &, *,

 

thanks  

0 Kudos
Message 1 of 11
(3,857 Views)
I'm not sure I fully understood your question.
 
Are you trying to program a routine that will ensure that the following characters are NOT entered?  !, @,#,$, %, &, *
 
If so, then you must first identify how you want the software to react when these characters are entered.  There are many ways of doing this.
 
Do you want to:
 
1.  completely ignore those characters?  which means you can type them as much as you want, the control will not display them.
2.  parse whatever you entered and remove them from the entry.
3. have a message to the operator saying that those characters are not permitted.
4. have the control change color when illegal characters are entered.
5. others..
 
Please let us know how you want to react to those characters so that we can recommend how to do it.
 
RayR
0 Kudos
Message 2 of 11
(3,846 Views)
Hi elyan,

please stick with your original thread!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 11
(3,844 Views)

Hi Gerd,

I think this is a different subject.  The other thread discussed limiting the string to 20 characters.

We can continue here.

RayR

0 Kudos
Message 4 of 11
(3,832 Views)

Make the key down? event to filter out unwanted characters.  Make sure that your control is set to update while typing.  If the character is not desired set the filter? to true else set it to false.  I do this often and it works great.

 

Paul.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 11
(3,826 Views)
RayR,

it's different, yes, but it concerns the same control, so it sticks together.....

And as i suggested in the other thread: Just use selection instead of free entry!
If i think about the given constraints of the string control
- No more than 20 characters
- No special Symbols
there are only few cases where selection is not possible:
- Usernames (which can be defined freely) and passwords
- Short labels for reports, ....

If such an entry is the case here, you should just verify the entry AFTER the user has entered the string and reset the control if the entry does not match showing the user within a dialog WHY the entry was descarded....

hope this helps,
Norbert
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 11
(3,817 Views)
Hi RayR
 
1.  have a message to the operator saying that those characters are not permitted. OR  have the control change color when illegal characters are entered.
 
 
Thanks
 
0 Kudos
Message 7 of 11
(3,809 Views)
Hi elyan and Joe,

both cases (limiting to 20 chars and allowing only specia chars) can be done using the same approach: event structure with "value change" (or "key down") event... That's the reason for saying "stick with original thread"!

After catching one of those events you can do all your checks (length, chars...) and set the control back to allowed values (or disregard the key down event)...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 11
(3,783 Views)

can you help me with this issue

 

thanks

0 Kudos
Message 9 of 11
(3,778 Views)

Sorry Gerd, I didn't mean to confuse the issue 😉 

Elyan,

Unfortunately, I do not have LV installed on this PC, otherwise I would gladly create an example. 

I will try to waljk you through the steps..  (hopfully my brain will cooperate 😉 )

Go to your block diagram.  Inside the programming Functions Palette, go into structures.  You will notice various loops.  Don't select those.  Loop for something called an "Event Structure" and place it on your block diagram, typically inside the loop which takes care of your user interface (user inputs).

If not already done, create a string control for your operator input.  Go to the Event Structure and right-click on the top edge.  Select "Create new event".  Then on the list (at the left), select the string control that I just mentionned. Now browse down the list on the right and select value change, or key down as Gerd mentionned.

Create a string array constant and write all the characters that you do not want, one in each element of the array.  Then compare this array with the input string and check if there are any matches (EQUAL).  Use an OR array elements.  This will tell you if there are any invalid characters.  Use a String Length to determine if the length is greater than 20. OR this with the output of the OR discussed above.

Use the output boolean to a Selector which will be used to change the background color iof your sting input control.  Right click the input string control and select create property node and choose text.backgound.text.color.  Place two color constants on the diagram, color one white and the other red.  Wire the white constant to the FALSE terminal of the Selector and the red to the TRUE.  Then wire the output of the selector to the property node.

What is described above will not automatically remove the bad characters, but then again, if you automatically discard tem, then why change the background color.

Hope this helps.

RayR 

0 Kudos
Message 10 of 11
(3,750 Views)