cancel
Showing results for 
Search instead for 
Did you mean: 

limit string control to number of bytes

SOLVED
LVCoder
Active Participant
Solved!

limit string control to number of bytes

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

7 REPLIES 7
mikeporter
Proven Zealot

Re: limit string control to number of bytes

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.
Kyle97330
Trusted Enthusiast

Re: limit string control to number of bytes

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.

altenbach
Knight of NI
Solution

Re: limit string control to number of bytes

Message contains a hyperlink

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

 

 

crossrulz
Knight of NI

Re: limit string control to number of bytes

Message contains a hyperlink

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



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
altenbach
Knight of NI

Re: limit string control to number of bytes

Message contains a hyperlink
mikeporter
Proven Zealot

Re: limit string control to number of bytes

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.
LVCoder
Active Participant

Re: limit string control to number of bytes

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.