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

Creating a new line in a textbox

Status
Not open for further replies.

reckdaman

Technical User
Apr 25, 2008
7
US
Hello,

Does anyone know how to create a new line in a text box. For instance, if I wanted to display 5 strings in one text box like:

------------
| String1 |
| String2 |
| String3 |
| String4 |
| String5 |
------------

I have tried many different things but with no luck.

Thanks!
 
Taken from Excel VBA help, but same should apply:

"If prompt consists of more than one line, you can separate the lines using a carriage return character (Chr(13)),
a linefeed character (Chr(10)), or carriage return – linefeed character combination (Chr(13) & Chr(10)) between each line.
 
Thanks Molby,

Unfortunately I tried that and it is not working. I get:

String1||String2|| etc....

Could it be a property I can add to the textbox to display these characters correctly (aka create the linefeed)?
 
Reck, what is your intent? Knowing that would help give better suggestions. Would a ComboBox work?

Code:
Sub main
   Dim ComboBox1() as String
   ReDim ComboBox1(10)
   
   For x = 0 to 10
       ComboBox1(x)= str(x)
   Next x
   Begin Dialog UserDialog 166, 142, "E! Basic Dialog Box"
      Text  9, 3, 69, 13, "Filename:", .Text1
      ComboBox  9, 14, 81, 119, ComboBox1(), .ComboBox1
      OKButton  101, 6, 54, 14
      CancelButton  101, 26, 54, 14
      PushButton 101, 52, 54, 14, "Help", .Push1
   End Dialog
   Dim mydialog as UserDialog
   On Error Resume Next
   Dialog mydialog
   If Err=102 then

      MsgBox "Dialog box canceled."
   End If
End Sub
How about a ListBox?
Code:
Sub main
   Dim ListBox1() as String
   ReDim ListBox1(10)
   
   For x = 0 to 10
       ListBox1(x)= str(x)
   Next x

   Begin Dialog UserDialog 133, 66, 171, 65, "E! Basic Dialog Box"
      Text  3, 3, 34, 9, "Directory:", .Text2
      ListBox  3, 14, 83, 39, ListBox1(), .ListBox2
      OKButton  105, 6, 54, 14
      CancelButton  105, 26, 54, 14
   End Dialog
   Dim mydialog as UserDialog
   On Error Resume Next
   Dialog mydialog
   If Err=102 then
      MsgBox "Dialog box canceled."
   End If
End Sub

[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 
MrMilson,

I'm trying to display a long list of information from the session in a dialog box. I currently use a listbox but there is no way for the user to copy specific info from the listbox and there is also a maximum number of entries in a listbox (some of the information being collected is over 1000 lines long).

I have considered dispaying the info in Excel or Word but it would be much better if I could dispay this in a textbox.

Thanks for your help!
 
This is what I did when I was having the same problem
Code:
NL$ = Chr$(10)
EndMsgtext$ = String1 & NL & String2 & NL & String3
MsgBox EndMsgtext

I changed the Chr$ number until I found the one that worked.
Hope this helps you
 
Well I have tried both Chr(10) and Chr(13) and both are just showing up as a verticle line, which means to me that they are not displaying properly in the textbox. I wonder if at this point it is a setting in the textbox properties that can make these display correctly.

I did verify that Chr(10) will create a new line in a message box, but that is not quite what I need.

Thanks
 
Dunno, I've never used a multi-line editbox to display info, not sure you can do it in EB. How much info is the user actually concerned with in those 1000+ lines. It seems there should be an easier solution but I don't have enough info to help.

[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 
If the Strings were all the same length could you change the size of the TextBox so that only one line would fit in a given width?
 
Good idea, but it still displays it all in one line even though no horizontal scroll bar is apparent. I can't find a way to put a new line in the text box even once the dialog is open since hitting enter closes the dialog box (hits the pushbutton). I'm still thinking it's a property setting for the textbox but I don't know what.
 
reck, what scripting language are you writing in? If it is VBA there is a multi-line property for the TextBox. There is not in EB.

[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 
Yes, I did see the multline property in VBA. Since it is not in EB I think this may be a lost cause. Thanks for your help
 
You need to use both carriage return and line feed in my experience. Try this:

Sub Main
msg1 = "Add a carriage return and a line feed" & chr(10) & chr(13)
msg1 = msg1 + "and see if it works for you." & chr(10) & chr(13)
msg1 = msg1 + "Good Luck."
msgbox msg1
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top