Type into next field if over certain character limit

How do i make sure to type into a next line when the string reaches a certain character?

E.g. String = “XXX LOS ANGELOS STREET XXXX MMMMMM SSSSS”
the address field is only 15 characters per line.
how do i break into and type into each line?

e.g.
XXX LOS ANGELOS
STREET XXX
MMMMMM SSSSS

If myStr.Length > 15

  • Then type into first box myStr.Left(15), type into second box myStr.Right(myStr.Len-15)
  • Else type into first box myStr

Maybe following Regex idea will help for keeping the words together within the max char length splits

[quote=“TyraS, post:1, topic:422176”]
XXX LOS ANGELOS STREET XXXX MMMMMM SSSSS
/(.{1,15})(|$) /gm
im having this error:
Your regular expression does not match the subject string.

please share with us the details from your implementation
grafik

strText
 "XXX LOS ANGELOS STREET XXXXX MMMMMM SSSSS"
 myMatches = Regex.Matches(strText, strPattern)
 MatchCollection(3) { [XXX LOS ANGELOS ], [STREET XXXXX ], [MMMMMM SSSSS] }
 myMatches.Cast(Of Match).Select(Function (m) m.Value).toArray
 string[3] { "XXX LOS ANGELOS ", "STREET XXXXX ", "MMMMMM SSSSS" }
 strPattern
 "(.{1,15})(\ |$)"

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.