Embedding a newline in strings

P

Phil Freihofner

Hi -

I would like to assemble the contents of several text
fields into a single text block, with some formatting. How
do I programmatically embed a newline? Within a text
field, one can press the key combination <ctrl><Enter> and
get a newline. For example, given str1 = "aaa" and str2
= "bbb", I would like to produce a new string = str1 &
newline & str2, or,

aaa
bbb

The following attempts did not work:
newstring = str1 & vbKeyReturn & str2
gives "aaa13bbb"


and
newstring = str1 & chr$(13) & str2

gives "aaa?bbb" where "?" is a small square box (undefined
char symbol?).

Note: I am trying to do this in the context of a function
call, not in an actual text field where I could use
conceivably use sendkeys.

Thanks in advance!

Phil Freihofner
Oakland
 
V

Van T. Dinh

Use:

str1 & Chr(13) & Chr(10) & str2

In VBA, you can use the intrinsic constant vbCrLf:

str1 & vbCrLf & str2
 
P

Phil Freihofner

Thank you, it works.
-----Original Message-----
Use:

str1 & Chr(13) & Chr(10) & str2

In VBA, you can use the intrinsic constant vbCrLf:

str1 & vbCrLf & str2

--
HTH
Van T. Dinh
MVP (Access)






.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top