06-30-2008 07:15 AM
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
06-30-2008 07:58 AM
06-30-2008 08:00 AM
06-30-2008 08:16 AM
Hi Gerd,
I think this is a different subject. The other thread discussed limiting the string to 20 characters.
We can continue here.
RayR
06-30-2008 08:25 AM
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.
06-30-2008 08:35 AM
06-30-2008 08:49 AM
06-30-2008 10:10 AM
06-30-2008 10:16 AM
can you help me with this issue
thanks
06-30-2008 12:09 PM
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