Page 1 of 1

About TextEntry

PostPosted: Thu Apr 21, 2016 1:54 am
by StarterPack
Hi Guys

I know that you can set a TextEntry box to allow only a certain amount of text, numbers etc. Is there a way that when i sized my TextEntry box to write to the end of the box and then it must stop. Cause when you use spaces in your words or numbers it also counts and then stops before the end.
And also when i use a TextEntry box with Multi-Line enable, if i'm at the last line end it must stop, so it must not scroll up.

Thank You

Re: About TextEntry

PostPosted: Thu Apr 21, 2016 10:10 am
by dpayer
How about something like this:
Code: Select all
StrLen "[textentry1]" "[text1len]"
If "[text1len]" ">" "[MaxStrLen]"
StickyNote "-1" "-1" "Maximum entry [MaxStrLen] characters" "500"
SubStr "[textentry1]" "1" "[MaxStrLen]" "[textentry1]"
SendKeys "" "{Tab}"
Endif


Put this in the "Text Change" tab of the Actions property for the text box. Set the variable for "[MaxStrLen]" to be the length you want.
The Stickynote is just to inform the user of the limitation. If more gets forced into the entry field, the SubStr will clip the right amount of characters and put them back in. The sendkeys tab will get the input out of the textbox.

You may want to make the max # characters to be one more than the desired amount so the user is informed of the limit.

Re: About TextEntry

PostPosted: Thu Apr 21, 2016 1:51 pm
by StarterPack
Hi dpayer

Thank You, this script i can use somewhere else, but is not what i'm looking for. If i create a TextEntry with 165 width i want to write till the box is full and then it must stop. Doesn't matter how many spaces i use. I can say that i only want 15 letters to be written in the box, but when you use spaces it will count as a number and it will not write till the end.

Example
THISISWHATIMEAN]box stops here - 15Letters
and
THIS IS WHAT I ]This is also 15Letters but with spaces and the problem is you don't know how many spaces the user uses to fill in a form.
I need this to print a form, but when you put too much letters in a box it will scroll forward and then you cannot print everything. When you say only 15 letters etc allowed then it won't write till the end of the box especially when they use spaces.

It would be great if you can write in the box and when it's at it's end the box expands automatically. But i guess not :)

Re: About TextEntry

PostPosted: Thu Apr 21, 2016 2:11 pm
by mishem
Image
Image
Image

Re: About TextEntry

PostPosted: Thu Apr 21, 2016 2:48 pm
by dpayer
dpayer wrote:updated:
Code: Select all
StrReplace "[textentry1]" " " "" "[textentryupdated1]" ""
StrLen "[textentryupdated1]" "[text1len]"
If "[text1len]" ">" "[MaxStrLen]"
SendKeys "" "{Tab}"
Endif


Put this in the "Text Change" tab of the Actions property for the text box.


This simply strips out the spaces (and if people put in other characters, you will need to replace those too). You can control what can be entered using the style section of the text entry properties.
You have to decide if you want to allow spaces or not. If you want to allow spaces to be entered, you can count them and then add that number to the maximum length of characters for your [MaxStrLen].

Re: About TextEntry

PostPosted: Thu Apr 21, 2016 2:52 pm
by StarterPack
HEHE :) GREAT STUFF

LOVE YOU MAN..... THANK YOU!!!!!

Re: About TextEntry

PostPosted: Thu Apr 21, 2016 3:00 pm
by StarterPack
dpayer, this works great, just what i need. Just out of curiosity, if i set my textentry to 400 width, can i also tell the script to write only that lenght?

Re: About TextEntry

PostPosted: Sat Apr 23, 2016 8:40 am
by dpayer
StarterPack wrote:dpayer, this works great, just what i need. Just out of curiosity, if i set my textentry to 400 width, can i also tell the script to write only that lenght?

Should not be a problem.

But if you are truly acting out of curiosity, then just try it and see if it works first! Then if there are problems, tell us what you tried.