Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to limit the number of characters in a texbox
PostPosted: Mon Jun 18, 2018 2:18 am 

Joined: Mon Jun 18, 2018 2:15 am
Posts: 1

Offline
Hello everyone
Trying to limit the number of characters a textbox can accept. There is no MaxLength property available. I have tried using the TextBox that comes through "Add Control" but it has no option to attach a tag. To summarize I am looking for a textbox control that can be attached to a tag and that has a MaxLength kind of property.
Thanks.


 Profile  
 
 Post subject: Re: How to limit the number of characters in a texbox
PostPosted: Mon Jun 18, 2018 2:16 pm 

Joined: Tue Jun 05, 2018 12:10 pm
Posts: 5

Offline
hi,

not sure if this fixes your problem but you can do this by the validation section in the Analog numeric. it has lower limit and upper limit.


Attachments:
Untitl2ed.png
Untitl2ed.png [ 134.51 KiB | Viewed 160 times ]
 Profile  
 
 Post subject: Re: How to limit the number of characters in a texbox
PostPosted: Mon Jun 18, 2018 2:26 pm 

Joined: Tue Jun 05, 2018 12:10 pm
Posts: 5

Offline
another idea.

create a new tag to have the "corected version"
so you will have two tags in your tags view:
yourOriginalTag ( data from where ever)
yourOriginalTag_corrected ( HMI tag will be changed by c#)

Code:
int minNum = 12 ;
int maxNum = 123 ;
var origTag = Globals.Tags.yourOriginalTag ;
var cappedTag = Globals.Tags.yourOriginalTag_corrected;

if   (Globals.Tags.yourOriginalTag.Value < minNum )
{
Globals.Tags.yourOriginalTag.Value = minNum ;
}

if   (Globals.Tags.yourOriginalTag.Value > maxNum )
{
Globals.Tags.yourOriginalTag.Value = maxNum ;
}


use the corrected in the textbox
and call that from some periodic/timed function from the screen ?


 Profile  
 
 Post subject: Re: How to limit the number of characters in a texbox
PostPosted: Wed Jun 20, 2018 1:33 am 

Joined: Fri Jan 27, 2012 4:20 am
Posts: 168

Offline
Hi, use script.
Globals.Tags.MyTag_rounded.Value =Math.Round((double)Globals.Tags.MyTag.Value,1);//rounds value to 1 decimal


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: