Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Label with two lines

Status
Not open for further replies.

sharonc

Programmer
Jan 16, 2001
189
US
Is it possible to create a label on a form with two lines in the label? If so how do you do this?
 
Dear Sharonc

A label should display multi lines by default, if this isn't the case with yours then I'm guessing that you have set the AutoSize property to TRUE (default is false). If this is the case you must also set the WordWrap property to TRUE (default is false). If you now resize the label - you should have multi-line text.

Another way is to set the caption from code, eg:

Label1.Caption = "first line text" & Chr(13) & "second line"

The above should work with any settings of AutoSize and WordWrap - chr(13) simply means start a new line and you can have as many chr(13) as you want.

Kate


 
Thank you for the information. It does do multiline, but I wanted it to break at certain places. Ex.
Max Mass
 
If you want both words on the same line, but spaced so it looks like two lines you can use the space function,i.e.:
Label1.Caption = "Max" & Space(5) & "Mass"
 
To make Enter do a carriage return (break to next line) press Shift+Enter
 
Faxof,
Using Shift+Enter does not work for the Caption property of a label at design-time in VB6. What version of VB are you using.
If I want multi-line captions, I put in a special character like | and then in the form_load
Dim ctl as control
For Each ctl in Controls
if Lcase$(TypeName(ctl)) = "label" then
Ctl.caption = Replace(ctl.Caption,"|",vbCrlf)
End if
Next
Compare Code (Text)
Generate Sort in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top