LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to limit string length

Hi
I would like to write a code to let the user type a certain text length into a string box. How can I do that?
Thanks
0 Kudos
Message 1 of 5
(3,761 Views)
A solution could be (if isn't too complicated in your case) to use an event structure.
Unfortunately this approach has its flaws...see the little vi attached.

regards,
manga
0 Kudos
Message 2 of 5
(3,748 Views)
You can also set the control setting 'update value while typing' on and check the string length in a while-loop. It's not nice but it works
0 Kudos
Message 3 of 5
(3,740 Views)
This version has a little correction...

bye,
manga
Message 4 of 5
(3,715 Views)
Hi Manga,

One issue with your VI appears when you paste text into the string control. That way there's a risk that the limit might be exceeded. Check out other threads that does take that case into account, for example this one:

Restricting text entry in string control to say 10 chars

Have fun!
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 5 of 5
(3,700 Views)