Solved

How to force a new line in text box - Excel userform

Posted on 2012-03-25
3
718 Views
Last Modified: 2012-03-25
Hello,

I have a userform that I would like to display a string of text in. I have built the string using the code below:

Private Sub UserForm_Initialize()
Dim rngComments As Range
Dim strcombuild As String
Set rngComments = Range("Comments")
strcombuild = ""
    With Me
        .CommandButton1.Caption = "Close"
    End With

For Each rw In rngComments.Rows
        i = 1
        If rw.Columns(1).Value = TaskID Then
        
            For Each cl In rw.Cells.Columns
                    If i = 1 Then
                        strcombuild = strcombuild & rw.Cells(1, i).Value
                    Else
                        strcombuild = strcombuild & " - " & rw.Cells(1, i).Value
                    End If
                    i = i + 1
            Next cl
            strcombuild = strcombuild & "." & vbNewLine
        End If
Next rw
Me.Textbox1 = strcombuild
End Sub

Open in new window


When I set Textbox1=strcombuild, it just displays one continuous line of text with like a paragraph marker where the carriage / line return should be.

When I assign Label1=strcombuild it displays fine.

I would like to have the text displayed on multiple lines in Textbox1 - any help would be appreciated.

Thanks,

Craig
0
Comment
Question by:slobber72
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
dlmille earned 500 total points
ID: 37763667
Just set the .MultiLine property of your textbox to true, and then your vbnewline will be represented in the textbox.

See attached.

Dave
multilineTextbox-r1.xls
0
 

Author Comment

by:slobber72
ID: 37763811
Thanks Dave. Much appreciated.
0
 
LVL 42

Expert Comment

by:dlmille
ID: 37763817
my pleasure.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question