Home All Groups Group Topic Archive Search About
Author
9 Jun 2005 11:40 PM
jack-e
Hi,


An easy on I'm guessing!


How do I restrict the length of a label? I have tried setting the width

to say 200px but if the user inputs a continuous line of characters
it's doesn't wrap.


Thanks in advance.


Jack

Author
10 Jun 2005 3:06 AM
societopia.net
The problem you have is not the width attribute of the label control rather
it is the continuous line of characters.  You will have to reformat any
string that is longer than the maximum length of your label.  Here is an
example of a function that you pass the string that you wish to space out
and the max length of the label that you wish to display:

Private Function SpaceOut(ByVal inputstring As String, ByVal len As Integer)
As String
    If inputstring.Length > len Then
        Return inputstring.Substring(0, len) & " " &
SpaceOut(inputstring.Substring(len + 1), len)
    Else
        Return inputstring
    End If
End Function

So if you have a text in a variable called LongLine that want to display in
a label named lblText, you would use it like this:
lblText.Text = SpaceOut(LongLine, 30)

---
http://www.societopia.net
http://www.webswapp.com


Show quoteHide quote
"jack-e" <jac***@humlog.com> wrote in message
news:1118360412.209388.16540@f14g2000cwb.googlegroups.com...
> Hi,
>
>
> An easy on I'm guessing!
>
>
> How do I restrict the length of a label? I have tried setting the width
>
> to say 200px but if the user inputs a continuous line of characters
> it's doesn't wrap.
>
>
> Thanks in advance.
>
>
> Jack
>

Bookmark and Share