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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOT DO I USE MULTIPLE LINES IN A LABEL'S CAPTION

Status
Not open for further replies.

opSpy

Programmer
May 18, 2002
18
DE
I am adding from a list into a label.caption, to print. But it just rewrites the caption, how do i move onto a new line??
 
try something like this

Code:
Dim i As Long

Label1.Caption = ""

For i = 0 To List1.ListCount - 1
  If List1.Selected(i) Then
    Label1.Caption = Label1.Caption & List1.List(i) & vbCrLf
  End If
Next i
 
The answer above is good, but I have some specifications to it, so let's rewrite it and see what I mean:
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
if i<>0 then Label1.Caption = Label1.Caption & vbCrLf
Label1.Caption = Label1.Caption & List1.List(i)
End If
Next i

I mean that you add the linefeed character (vbCrLf or chr$(13)) only if needed, I mean only if it is a next item to add, otherwise the caption would contain an unneeded linefeed and may cause problems when redimensioned.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top