Embed linefeed in string

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,

I would like to have the text of a button or label display as two lines rather than on a single line. The way to do this is to embed a line feed (Chr(10)) in the string at the desired line break point.

for example,
Code: Copy
but1.Text = "Hit" & Chr(10) & "Me"
displays "Hit Me" on two lines within a button

Is there an easier way to embed a Chr(10) character?
I know "Hit\nMe" does not do the trick.

Thanks,
Barry.
 
but1.Text = "Hit" & crlf & "Me"

--- Jem
 
Upvote 0
Add the sub below and then just enter your text in the lf() function. Use any character you know you will not be using in your buttons. I used * but you can use anything you want, just replace it in the sub as well.
The sample below returns:

My Button
Text

Code: Copy
but1.Text = lf("My Button*Text")

Sub lf(Text As String) As String
   Return Text.Replace("*", Chr(10))
End Sub

So you will be typing:

but1.Text = lf("Hit*Me")

vs

but1.Text = "Hit" & Chr(10) & "Me"
 
Last edited:
Upvote 0
Add the sub below and then just enter your text in the lf() function. Use any character you know you will not be using in your buttons. I used * but you can use anything you want, just replace it in the sub as well.
The sample below returns:

My Button
Text

Code: Copy
but1.Text = lf("My Button*Text")

Sub lf(Text As String) As String
   Return Text.Replace("*", Chr(10))
End Sub

Now that's a cool idea.

Thanks,
Barry
 
Upvote 0
Back
Top