×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Creating a new line in a textbox

Creating a new line in a textbox

Creating a new line in a textbox

(OP)
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!

RE: Creating a new line in a textbox

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."

RE: Creating a new line in a textbox

(OP)
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)?

RE: Creating a new line in a textbox

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

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

RE: Creating a new line in a textbox

(OP)
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!

RE: Creating a new line in a textbox

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

RE: Creating a new line in a textbox

(OP)
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

RE: Creating a new line in a textbox

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.

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

RE: Creating a new line in a textbox

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?

RE: Creating a new line in a textbox

(OP)
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.

RE: Creating a new line in a textbox

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.

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

RE: Creating a new line in a textbox

(OP)
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

RE: Creating a new line in a textbox

Is there any reason it has to be in EB?

RE: Creating a new line in a textbox

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close