Click to See Complete Forum and Search --> : Removing Carrage Returns
Beth Poka
August 17th, 2001, 10:33 AM
Hi There,
I have a control that has a text box that allows users to enter text. How do I delete/remove the carriage returns if the users did not enter any text and hit the carriage return key on the keyboard a few times.
Thanks in Advance
Beth
Iouri
August 17th, 2001, 10:37 AM
Replace function very useful when I want to avoid too many append operations just to insert
non-printable characters.
Replace(Text1,vbCrLf,"")
Iouri Boutchkine
iouri@hotsheet.com
Beth Poka
August 17th, 2001, 11:32 AM
I need to search for lines that only has vbCrLf and remove them, but leaving those lines that containing text.
Iouri
August 17th, 2001, 01:00 PM
Check the length of the line. If len(line) = 0 then remove vbcrlf
Iouri Boutchkine
iouri@hotsheet.com
Beth Poka
August 17th, 2001, 01:14 PM
Sorry, I'm very new to VB Programming. Is there a function for remove vbCrLf as you mentioned
Thanks for all your help
Beth Poka
August 17th, 2001, 01:50 PM
Here is my code
If Len(ctlTextBox.Text) = 0 Then
ctlTextBox.Text = ""
Else
ctlTextBox.Text=ctlTextBox.Text & vbCrLf
End if
If I hit the return key a few time on my keyboard in the text box. ctlTextBox.Text gives me "llll"(not exactly as shown, it more vertical barcode marks in bold). It is indicating it is not 0.
Appreciate your help.
Beth
Iouri
August 17th, 2001, 02:12 PM
Your code is not going to do anything but add the vbcrlf at the end of the text box.
What you have to do is read the text between the vbcrlf using InStr function. If the length of the line between vbcrlf is = 0 then replace the vbcrlf with "". Otherwise do not do anything
Iouri Boutchkine
iouri@hotsheet.com
Iouri
August 20th, 2001, 09:00 AM
Replace function will substitute vbcrlf with "" (or whatever you want to)
Iouri Boutchkine
iouri@hotsheet.com
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.