Solved

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

Posted on 2012-03-25
3
641 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
  • 2
3 Comments
 
LVL 41

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 41

Expert Comment

by:dlmille
ID: 37763817
my pleasure.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

809 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