LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Byte count in a textbox

Solved!
Go to solution

I have a database application in that all the textboxes have a limit on the bytes user can write into. I'm thinking whether we can have a way to limit the number of bytes a user can enter into a textbox. I haven't found any property or method that can serve the purpose. Any one can provide some advices?

 

Thanks and best regards,

 

Guangde Wang

0 Kudos
Message 1 of 8
(3,874 Views)
Solution
Accepted by topic author guangdew1

You can try it with the string control set to update while typing and then disable it from a 'calue change' event when it reaches the maximum length

 

 

0 Kudos
Message 2 of 8
(3,868 Views)

Guangde,

 

you have to read the string, check it's size and limit it if necessary. You can use an event structure to read the string at each key pressed (key down of string control) and then decide if to discard either the first or the last character....

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 8
(3,868 Views)

Thank you for responding to my post. After I clicked Solution and tried to play it further, I got another question.

 

In your example, you have the textbox disabled if the byte count is over the limit. It worked okay that way. But when I tried to changed the Disabled property to Blinking, it behaved differently.  With Disabled, it counts the bytes while typing. But after I changed it to Blinking, I have to move the focus away from the control textbox then it can recognize it's over the limit. Do you have any explanation?

 

Guangde

0 Kudos
Message 4 of 8
(3,848 Views)
It looks like the control doesn't blink as long as there is focus in that control.
0 Kudos
Message 5 of 8
(3,834 Views)

That's something I feel don't understand. In the original example, we don't have to have the focus away from the textbox. The program knows it's over limit while typing, but I don't know why in this setup, it will not blink.

 

Guangde

0 Kudos
Message 6 of 8
(3,831 Views)

I don't think it has anything to do with the event structure or the comparison.  Just that the text box doesn't blink when the cursor is inside of it.

 

Type it a bunch of characters.  Leave.  It blinks.  Click back in it and don't type anything.  It stops blinking.  Click out, it blinks again.  It is just the nature of the blinking property.  I don't think it is a bad thing.  I think it would be annoying to have a control blinking at you while typing in it.

 

An alternative might be to set the color of the text box to something else when you are over the limit on characters.  Set it back to white when you are okay.

0 Kudos
Message 7 of 8
(3,823 Views)

I realized that it's the nature of the Blinking property. I made it into a color change and it worked beautifully.

 

Thanks for your help.

 

Guangde

0 Kudos
Message 8 of 8
(3,816 Views)