Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Excel VBA - carriage returns

Hi,

I am writing some vba code to split up some text that has
been entered in textboxes, and in every case there appears
to be carriage returns at the end of each line. Is there
a way I can strip out each line and store it in to a
seperate variable (eg line1,line2,line3 and line4 - there
are a maximum of 4 lines per textbox)?

Many thanks
KD
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Excel VBA - carriage returns

Hi KD

Linebreaks are either Ascii 10 or Ascii 13 or combinations of the two. If
you use Excel 200 or above on Windows, try Replace:

Sub test()
Dim S As String
S = "Hello" & vbNewLine & _
"world" & Chr(13) & _
"how" & vbCrLf & _
"are" & Chr(10) & "You?"
MsgBox S
S = Replace(S, Chr(10), " ")
S = Replace(S, Chr(13), " ")
S = Replace(S, " ", " ")
MsgBox S
End Sub

HTH. Best wishes Harald

"KD" skrev i melding
...
Hi,

I am writing some vba code to split up some text that has
been entered in textboxes, and in every case there appears
to be carriage returns at the end of each line. Is there
a way I can strip out each line and store it in to a
seperate variable (eg line1,line2,line3 and line4 - there
are a maximum of 4 lines per textbox)?

Many thanks
KD



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
viewing carriage returns in excel 7 schackbo Excel Discussion (Misc queries) 1 December 18th 09 12:42 PM
Remove carriage returns in an Excel document? smartnfunnyfem Excel Discussion (Misc queries) 3 August 26th 08 10:21 PM
Removing carriage returns from excel Luvsql Excel Worksheet Functions 9 March 20th 07 05:59 PM
Carriage Returns Excel 2003 Zoddy Excel Discussion (Misc queries) 0 August 15th 06 01:35 PM
Removing Carriage Returns in Excel 2000 Toby Stevenson Excel Discussion (Misc queries) 5 June 2nd 05 12:25 AM


All times are GMT +1. The time now is 05:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"