LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

limit string control to number of bytes

Solved!
Go to solution

Hi,

 

Is there a way to set the limit on the length of string control in number of bytes? I have a string control whose length is always going to be 3 bytes and I don't want the user to accidentally enter more bytes.

What I have done right now is have a value change event on the string and display only the 1st 3 bytes whenever the value change event occurs but I want to know if there is any direct way to set the limit on the number of bytes on the string control.

 

Thanks,

Ritesh

0 Kudos
Message 1 of 8
(4,303 Views)
Yes, set the string control to update while typing, then create a value change event on the control that tests the length of the contents. This event will fire with each key stroke.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 8
(4,288 Views)

Did you set the "update while typing" property to True so that you can delete extra characters immediately after they are added instead of after people type for a while?

 

Apart from doing that I don't know of a way, though.

0 Kudos
Message 3 of 8
(4,285 Views)
Solution
Accepted by topic author LVCoder

This has been discussed many times in the past. For example look here.

 

 

0 Kudos
Message 4 of 8
(4,280 Views)

And go give this idea a kudo: Option to Limit the Number of Characters in a String Control


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 8
(4,275 Views)

Another related idea would be to have a fixed lenght string datatype as described in this idea. 😄

0 Kudos
Message 6 of 8
(4,268 Views)
No, update while typing is set so the event will fire with each key stroke.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 8
(4,234 Views)

Thanks everyone! 

I am already using "String value change" event to capture the change and then displaying only the 1st 3 bytes, but altenbach's answer is more elegant that it doesn't allow keystrokes event if the number of bytes have already reached the limit, so I accepted that as a solution.

 

I was only hoping to find a direct property of a string control to limit the number of bytes. It seems like the rquest has been submitted mutiple times so I did my part and kudoed those requests.

0 Kudos
Message 8 of 8
(4,177 Views)