PC Review


Reply
Thread Tools Rate Thread

Carriage Return Characters - Chr(10)

 
 
AussieDave
Guest
Posts: n/a
 
      30th Jun 2008
Each data cell has multiple lines, delineated by a Chr(10) , which
looks perfectly good on the worksheet. However, when initialising a
UserForm with this data, each Chr(10) is duplicated. This only
becomes apparent when I save the data from the Form back to the
worksheet and can then see the superfluous Chr(10) shown as a small
box at the end of each line of data. Hoping someone can help me get
rid of the extra ones. Thanks in advance, Dave.
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      30th Jun 2008
You need to adjust the width of the column. One return is being caused by
the chr(10), and the other return is due to the column width being too narrow
for the data and th eline is wrapping.

"AussieDave" wrote:

> Each data cell has multiple lines, delineated by a Chr(10) , which
> looks perfectly good on the worksheet. However, when initialising a
> UserForm with this data, each Chr(10) is duplicated. This only
> becomes apparent when I save the data from the Form back to the
> worksheet and can then see the superfluous Chr(10) shown as a small
> box at the end of each line of data. Hoping someone can help me get
> rid of the extra ones. Thanks in advance, Dave.
>

 
Reply With Quote
 
AussieDave
Guest
Posts: n/a
 
      30th Jun 2008
Thanks Joel, but that's not the case here. Even when a Chr(10) has
been inserted just to get a blank line, the duplication is still
occurring.
Dave

On Jun 30, 3:19*pm, Joel <J...@discussions.microsoft.com> wrote:
> You need to adjust the width of the column. *One return is being causedby
> the chr(10), and the other return is due to the column width being too narrow
> for the data and th eline is wrapping.

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      30th Jun 2008
Are you gewtting two lines or three lines when you put chr(10) into the form?
You should get two because you start with one Line and putting the chr(10)
creates a second line.

"AussieDave" wrote:

> Thanks Joel, but that's not the case here. Even when a Chr(10) has
> been inserted just to get a blank line, the duplication is still
> occurring.
> Dave
>
> On Jun 30, 3:19 pm, Joel <J...@discussions.microsoft.com> wrote:
> > You need to adjust the width of the column. One return is being caused by
> > the chr(10), and the other return is due to the column width being too narrow
> > for the data and th eline is wrapping.

>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      30th Jun 2008
I put a couple of buttons and a textbox on a small userform.

This was the code behind the userform:

Option Explicit
Private Sub CommandButton1_Click()
With Worksheets("Sheet1").Range("b1")
.WrapText = True
.Value = Replace(Me.TextBox1.Value, vbCr, "")
End With
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Me.TextBox1
.MultiLine = True
.WordWrap = True
.EnterKeyBehavior = True
.Value = Worksheets("Sheet1").Range("A1").Value
End With
End Sub



AussieDave wrote:
>
> Each data cell has multiple lines, delineated by a Chr(10) , which
> looks perfectly good on the worksheet. However, when initialising a
> UserForm with this data, each Chr(10) is duplicated. This only
> becomes apparent when I save the data from the Form back to the
> worksheet and can then see the superfluous Chr(10) shown as a small
> box at the end of each line of data. Hoping someone can help me get
> rid of the extra ones. Thanks in advance, Dave.


--

Dave Peterson
 
Reply With Quote
 
Charlie
Guest
Posts: n/a
 
      30th Jun 2008
FYI, Chr(10) is a Linefeed, not a Carriage Return. Use vbLf instead of vbCr.

"Dave Peterson" wrote:

> I put a couple of buttons and a textbox on a small userform.
>
> This was the code behind the userform:
>
> Option Explicit
> Private Sub CommandButton1_Click()
> With Worksheets("Sheet1").Range("b1")
> .WrapText = True
> .Value = Replace(Me.TextBox1.Value, vbCr, "")
> End With
> End Sub
> Private Sub CommandButton2_Click()
> Unload Me
> End Sub
> Private Sub UserForm_Initialize()
> With Me.TextBox1
> .MultiLine = True
> .WordWrap = True
> .EnterKeyBehavior = True
> .Value = Worksheets("Sheet1").Range("A1").Value
> End With
> End Sub
>
>
>
> AussieDave wrote:
> >
> > Each data cell has multiple lines, delineated by a Chr(10) , which
> > looks perfectly good on the worksheet. However, when initialising a
> > UserForm with this data, each Chr(10) is duplicated. This only
> > becomes apparent when I save the data from the Form back to the
> > worksheet and can then see the superfluous Chr(10) shown as a small
> > box at the end of each line of data. Hoping someone can help me get
> > rid of the extra ones. Thanks in advance, Dave.

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      30th Jun 2008
I want to keep the linefeeds so the text wraps in the cell. I want to remove
the carriage returns so I don't see those little square characters.

That's why I used:
..Value = Replace(Me.TextBox1.Value, vbCr, "")



Charlie wrote:
>
> FYI, Chr(10) is a Linefeed, not a Carriage Return. Use vbLf instead of vbCr.
>
> "Dave Peterson" wrote:
>
> > I put a couple of buttons and a textbox on a small userform.
> >
> > This was the code behind the userform:
> >
> > Option Explicit
> > Private Sub CommandButton1_Click()
> > With Worksheets("Sheet1").Range("b1")
> > .WrapText = True
> > .Value = Replace(Me.TextBox1.Value, vbCr, "")
> > End With
> > End Sub
> > Private Sub CommandButton2_Click()
> > Unload Me
> > End Sub
> > Private Sub UserForm_Initialize()
> > With Me.TextBox1
> > .MultiLine = True
> > .WordWrap = True
> > .EnterKeyBehavior = True
> > .Value = Worksheets("Sheet1").Range("A1").Value
> > End With
> > End Sub
> >
> >
> >
> > AussieDave wrote:
> > >
> > > Each data cell has multiple lines, delineated by a Chr(10) , which
> > > looks perfectly good on the worksheet. However, when initialising a
> > > UserForm with this data, each Chr(10) is duplicated. This only
> > > becomes apparent when I save the data from the Form back to the
> > > worksheet and can then see the superfluous Chr(10) shown as a small
> > > box at the end of each line of data. Hoping someone can help me get
> > > rid of the extra ones. Thanks in advance, Dave.

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
AussieDave
Guest
Posts: n/a
 
      2nd Jul 2008
Thanks Dave - as usual, you're right on the button, it works
perfectly.

Thanks also to all others who contributed. Dave

On Jul 1, 7:19*am, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> I want to keep the linefeeds so the text wraps in the cell. *I want to remove
> the carriage returns so I don't see those little square characters. *
>
> That's why I used:
> .Value = Replace(Me.TextBox1.Value, vbCr, "")
>
>
>
>
>
> Charlie wrote:
>
> > FYI, Chr(10) is a Linefeed, not a Carriage Return. *Use vbLf instead of vbCr.

>
> > "Dave Peterson" wrote:

>
> > > I put a couple of buttons and a textbox on a small userform.

>
> > > This was the code behind the userform:

>
> > > Option Explicit
> > > Private Sub CommandButton1_Click()
> > > * * With Worksheets("Sheet1").Range("b1")
> > > * * * * .WrapText = True
> > > * * * * .Value = Replace(Me.TextBox1.Value, vbCr, "")
> > > * * End With
> > > End Sub
> > > Private Sub CommandButton2_Click()
> > > * * Unload Me
> > > End Sub
> > > Private Sub UserForm_Initialize()
> > > * * With Me.TextBox1
> > > * * * * .MultiLine = True
> > > * * * * .WordWrap = True
> > > * * * * .EnterKeyBehavior = True
> > > * * * * .Value = Worksheets("Sheet1").Range("A1").Value
> > > * * End With
> > > End Sub

>
> > >AussieDavewrote:

>
> > > > Each data cell has multiple lines, delineated by a Chr(10) , which
> > > > looks perfectly good on the worksheet. *However, when initialisinga
> > > > UserForm with this data, each Chr(10) is duplicated. *This only
> > > > becomes apparent when I save the data from the Form back to the
> > > > worksheet and can then see the superfluous Chr(10) shown as a small
> > > > box at the end of each line of data. *Hoping someone can help me get
> > > > rid of the extra ones. *Thanks in advance, Dave.

>
> > > --

>
> > > Dave Peterson

>
> --
>
> Dave Peterson- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2007 showing carriage return characters Doug Microsoft Outlook Discussion 0 9th Apr 2009 08:03 PM
strange characters appear when I use space bar or carriage return =?Utf-8?B?UmFuZG9tdGhvdWdodA==?= Microsoft Outlook Discussion 2 28th Jun 2007 11:02 PM
URGENT! Problem with carriage return & square characters! dabooj Microsoft Access External Data 2 15th Aug 2006 03:45 PM
Read textfile. Carriage Return Characters. =?Utf-8?B?TmF0aGFuIFRheWxvcg==?= Microsoft Dot NET Framework 4 20th Nov 2005 09:46 PM
Line feed - carriage return characters Arthur H. MacLeod Microsoft Access Reports 1 28th Dec 2003 07:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:21 AM.