Assigning Multi line text to a multiline text box 
Author Message
 Assigning Multi line text to a multiline text box

I have a multiline textbox to  which i would line to assign 2 lines of text
to appear on 2 lines. I have tried the following but without joy.

address = "house number" + chr$(10) + chr$(13) + "street name"
text1.text = address

but i get

house number||street name

appear in the textbox

I also tried assigning the lines individually text1.text(1) = "house number"
etc but got a write protect error



Fri, 13 Jul 2001 03:00:00 GMT  
 Assigning Multi line text to a multiline text box
On Mon, 25 Jan 1999 09:18:36 +0100, "A Bit Scruffy"

Quote:

>I have a multiline textbox to  which i would line to assign 2 lines of text
>to appear on 2 lines. I have tried the following but without joy.

>address = "house number" + chr$(10) + chr$(13) + "street name"
>text1.text = address

>but i get

>house number||street name

>appear in the textbox

>I also tried assigning the lines individually text1.text(1) = "house number"
>etc but got a write protect error

You need to set text1.multiline = True. Hope this helps

Ole
-
Ole I. Hougaard



Fri, 13 Jul 2001 03:00:00 GMT  
 Assigning Multi line text to a multiline text box
You're right Chr$(10) & Chr$(13) does not do what you want, but there is a
easy fix.

Swap them (13 before 10)

or simply use the predefined vbCrLf, which is, of course, Carriage Return
Line Feed

Quote:
>address = "house number" + chr$(10) + chr$(13) + "street name"
>text1.text = address

>but i get

>house number||street name



Fri, 13 Jul 2001 03:00:00 GMT  
 Assigning Multi line text to a multiline text box
You've got the line feed and the carriage return in the wrong order.
Chr$(13) should come before Chr$(10). Better still, use the constant vbCrLf
instead.

Mike

Quote:

>I have a multiline textbox to  which i would line to assign 2 lines of text
>to appear on 2 lines. I have tried the following but without joy.

>address = "house number" + chr$(10) + chr$(13) + "street name"
>text1.text = address

>but i get

>house number||street name

>appear in the textbox

>I also tried assigning the lines individually text1.text(1) = "house
number"
>etc but got a write protect error



Fri, 13 Jul 2001 03:00:00 GMT  
 Assigning Multi line text to a multiline text box

Quote:

>Just change your code as below;

>address = "house number" + Chr$(13) + Chr$(10) + "street name"
>Text1.Text = address

1) Get in the habit of using "&" instead of "+" for string concatenation,
to avoid accidentally adding a string of digits to an integer in other
statements.

2) Since VB4, there are built-in constants that are much more self-documenting
than Chr$(number) calls:

  vbCr
  vbLf
  vbCrLf

You want the last one for this use.  For MsgBox text, use vbLf.

-- Rick
--

(Rick Rutt is a system architect living and working in metropolitan Detroit.)



Sat, 14 Jul 2001 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. How to get centered text on a none multi line text box (VB4)

2. How to get centered text on a none multi line text box (VB4)

3. Printing other lines from Multi-Line text box

4. Line numbers into multi-line text box

5. ? Text Box: multi line; fixed length per line

6. Starting new line on multiline text box

7. Line length & count for multiline Text Box

8. Reading a single line in a multiline text box

9. Adding text to a multiline text box

10. Displaying text in a multiline text box

11. How to print MultiLine Text from Text box

12. multi line text box

 

 
Powered by phpBB® Forum Software