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

Carriage Return Won't Work in a Text Box 1

Status
Not open for further replies.

wisgro

Technical User
Mar 5, 2008
25
US
I have a list box that is automatically populated when the form loads. When a user selects a name in the list box the name is displayed in a text box. The text box is set to multiline but no matter which carriage return code I use only one line is printed. Selection one is replaced by selection two, etc. Advice greatly appreciated.

Private Sub Form_Load()
Dim strAppliance As String

Open "C:\VB Projects\Appliance_List\Appl_Names.txt" For Input As #1
lstAppliances.Clear

Do Until EOF(1)
Input #1, strAppliance

With lstAppliances
.AddItem strAppliance
End With
Loop
Close #1
End Sub

Private Sub lstAppliances_Click()
If lstAppliances.ListIndex > -1 Then
txtOutput.Text = lstAppliances.List(lstAppliances.ListIndex) & vbNewLine
End If
End Sub
 
You are replacing the contents of the textbox with this line:

txtOutput.Text = lstAppliances.List(lstAppliances.ListIndex) & vbNewLine

You should be trying something like:

txtOutput.Text = txtOutput.Text & lstAppliances.List(lstAppliances.ListIndex) & vbCRLF
 
Thank you for responding so quickly. Your suggestion works perfectly. Now for the next hurdle.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top