473,378 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

I don't remember carriage and return

Hi all,

this is simple, but I don't remember how to seperate the a lengthy string
into 2 or more lines. I did this long time ago, if I have the code like this
can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2

Nov 13 '05 #1
4 1376
Try:
MyString = string1 & Chr(13) & Chr(10) & string2

In VBA code, you can use the constant vbCrLf or vbNewLine:
MyString = string1 & vbCrLf & string2

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:mg*******************@news20.bellglobal.com.. .
Hi all,

this is simple, but I don't remember how to seperate the a lengthy string
into 2 or more lines. I did this long time ago, if I have the code like this can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2

Nov 13 '05 #2
Hi "JingleBEV",

In the Access2.0 days, it would have been "Chr$(10) & Chr$(13)" ... (well,
technically, it still works) but since Access97 "Chr$(10) & Chr$(13)" has
been replaced by "vbCrLf"

So to correct your string as posted...
string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & Chr$(10) & Chr$(13) & string2
Either way, here is an example of how I would have wrote this using a single
string variable for the message, along with another to represent the
carriage return:

***********************************
....
Dim Msg As String
Dim CR As String

CR = Chr$(10) & Chr$(13) ' Access 2.0
'CR = vbCrLf ' Access97

Msg = ""
'I am in the habit of ensuring that my string variables are empty before
proceeding

Msg = Msg & "this is the first string " & CR
Msg = Msg & "and this is the second string."

MsgBox(Msg)
....
***********************************
Don

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:mg*******************@news20.bellglobal.com.. .
Hi all,

this is simple, but I don't remember how to seperate the a lengthy string
into 2 or more lines. I did this long time ago, if I have the code like this can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2

Nov 13 '05 #3
Chr$(10) & Chr$(13) = LfCr

Chr$(13) & Chr$(10) = CrLf

Which can give different results

--
Terry Kreft
MVP Microsoft Access
"Don Leverton" <le****************@telusplanet.net> wrote in message
news:hj4Gc.59415$_5.28301@clgrps13...
Hi "JingleBEV",

In the Access2.0 days, it would have been "Chr$(10) & Chr$(13)" ... (well, technically, it still works) but since Access97 "Chr$(10) & Chr$(13)" has
been replaced by "vbCrLf"

So to correct your string as posted...
string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & Chr$(10) & Chr$(13) & string2
Either way, here is an example of how I would have wrote this using a single string variable for the message, along with another to represent the
carriage return:

***********************************
...
Dim Msg As String
Dim CR As String

CR = Chr$(10) & Chr$(13) ' Access 2.0
'CR = vbCrLf ' Access97

Msg = ""
'I am in the habit of ensuring that my string variables are empty before
proceeding

Msg = Msg & "this is the first string " & CR
Msg = Msg & "and this is the second string."

MsgBox(Msg)
...
***********************************
Don

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:mg*******************@news20.bellglobal.com.. .
Hi all,

this is simple, but I don't remember how to seperate the a lengthy string into 2 or more lines. I did this long time ago, if I have the code like

this
can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2


Nov 13 '05 #4
Thanks to all your inputs
This is the one I was looking for
MyString = string1 & Chr(13) & Chr(10) & string2

and vbCrLf new to me. Thanks

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@per-qv1-newsreader-01.iinet.net.au...
Try:
MyString = string1 & Chr(13) & Chr(10) & string2

In VBA code, you can use the constant vbCrLf or vbNewLine:
MyString = string1 & vbCrLf & string2

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"JingleBEV" <n_****@NOSPAMyahoo.com> wrote in message
news:mg*******************@news20.bellglobal.com.. .
Hi all,

this is simple, but I don't remember how to seperate the a lengthy string into 2 or more lines. I did this long time ago, if I have the code like

this
can someone correct it please

string1 = "this is the first string"
string2 = "this is the second string"
mystring = string1 & 10 & 13 & string2


Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Canes_Rock | last post by:
The information posted at: ...
4
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to...
4
by: Josh | last post by:
Hi, I'm using System.Data.DataSet.ReadXml to convert some xml from a webservice to a DataSet. The xml looks like: <?xml version="1.0"...
2
by: Andrew Chanter | last post by:
I have a VBA function that returns a string including "vbcr" (VB Carriage Return) to seperate a list into multiple rows, eg Item1 & vbcr & Item2 & vbcr & Item3 This works as planned in the...
2
by: eagleofjade | last post by:
I am trying to import data from a Word document into an Access table with VBA. The Word document is a form which has various fields. One of the fields is a field for notes. In some cases, this...
3
by: Dinsdale | last post by:
I have an xml file that is read into an object using serialization. One of the objects has a string field called delimeter that I want to contain a carriage return. Instead of trying to include the...
6
by: shajias | last post by:
Hi, I am having a xml code like this <name> I am having a carriage return here. Second line with carriage return. This is the last line. </name>
11
by: evenlater | last post by:
My db allows the user to send email via CDO. The body of the email is determined in code. I have built an email form with To, CC and Subject lines and a large text box for the body of the message...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.