Clear line breaks in strings

Source: Internet
Author: User
Tags printable characters

In actual application scenarios, the address entered by the customer contains carriage return and line breaks, resulting in an error in format conversion. Therefore, you need to clear the line. There are two methods:


1. Replace. This method can only clear one carriage return line break.
'Check whether there is a line break in the address
ADDR = cells (row1, 12)
If instr (1, ADDR, CHR (10), vbbinarycompare)> 0 then
Msgbox ADDR
ADDR = Replace (ADDR, CHR (10), "", vbbinarycompare)
ADDR = Replace (ADDR, CHR (13), "", vbbinarycompare)
Msgbox ADDR
Cells (row1, 12) = ADDR
End if
2. Use the system function to clear all non-printable characters.
'Check whether there is a line break in the address
ADDR = cells (row1, 12)
If instr (1, ADDR, CHR (10), vbbinarycompare)> 0 then
Msgbox ADDR
ADDR = application. worksheetfunction. Clean (ADDR)
Msgbox ADDR
Cells (row1, 12) = ADDR
End if
Want to know moreProgramming Language tutorial setYou can log on to e liangshi Yiyou.

Clear line breaks in strings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.