How to show chr(13) in a Textbox ????? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to show chr(13) in a Textbox ?????

Hi,

When I have a textstring like: subject="This is" + Chr(13) + "a test"

So that it will print on 2 lines
when I put it in the textbox.text
then it's 1 line and where the Enter suppose to be there's a black square.

How to fix this ?

Many Thanks


Comments

  • : Hi,
    :
    : When I have a textstring like: subject="This is" + Chr(13) + "a test"
    :
    : So that it will print on 2 lines
    : when I put it in the textbox.text
    : then it's 1 line and where the Enter suppose to be there's a black square.
    :
    : How to fix this ?
    :
    : Many Thanks
    : You can do that by setting the Text Box Multiline property to True.



  • That one is already set to True.
    When I just type in the box, then everything is normal.
    But when I do it like that then it's just 1 row, even if multiline is enabled.

    Perry


  • Forgot to tell
    that I tried textbox.multiline = True

    but then when I start the program, i'll get a Read-only error



  • : That one is already set to True.
    : When I just type in the box, then everything is normal.
    : But when I do it like that then it's just 1 row, even if multiline is enabled.
    :
    : Perry
    :
    What I can say is if you want to make a new line you should use VBnewline consonant or Chr(13) & chr(10)

    Example:

    Dim TEST as string
    TEST = "No1" & vbnewline & "No2"
    or

    TEST = "No1" & chr(10) & chr(13) & "No2"




  • : Hi,
    :
    : When I have a textstring like: subject="This is" + Chr(13) + "a test"
    :
    : So that it will print on 2 lines
    : when I put it in the textbox.text
    : then it's 1 line and where the Enter suppose to be there's a black square.
    :
    : How to fix this ?
    :
    : Many Thanks
    :

    Try:

    subject = "This is" & vbCRLF & "a test"

    Always use the ampersand for string concatenation, not the plus sign. This could lead to problems if numerical strings are involved.


  • : That one is already set to True.
    : When I just type in the box, then everything is normal.
    : But when I do it like that then it's just 1 row, even if multiline is enabled.
    :
    : Perry
    :
    What I can say is if you want to make a new line you should use VBnewline consonant or Chr(13) & chr(10)

    Example:

    Dim TEST as string
    TEST = "No1" & vbnewline & "No2"
    or

    TEST = "No1" & chr(13) & chr(10) & "No2"




  • Hi all,

    Thank you very much.

    it's working now.

    Now I'm gonna figure out my other problem.


    Thanks Again.



  • Bandit127Bandit127 Posts: 3Member
    : : Hi,
    : :
    : : When I have a textstring like: subject="This is" + Chr(13) + "a test"
    : :
    : : So that it will print on 2 lines
    : : when I put it in the textbox.text
    : : then it's 1 line and where the Enter suppose to be there's a black square.
    : :
    : : How to fix this ?
    : :
    : : Many Thanks
    : :
    :
    : Try:
    :
    : subject = "This is" & vbCRLF & "a test"
    :
    : Always use the ampersand for string concatenation, not the plus sign. This could lead to problems if numerical strings are involved.
    :
    :

    Since very early on in computers ('60s?), a new line is represented by
    LF (line feed) CHR$(13) hex 0D
    CR (carriage return) CHR$(10) hex 0A
    This was for control of line printers, telytypes and electronic typewriters.
    It's stuck. Use "debug" on the command line to see 0D 0A in any text file for a new line.

    vbCRLF represents 0D 0A concatenated in the right order which is why Machaira's solution is good.






Sign In or Register to comment.