devxlogo

Avoid append operations with the Replace function

Avoid append operations with the Replace function

I find the Replace function very useful when I want to avoid too many append operations just to insert non-printable characters. For example, the following statement:

MsgBox "Disk not ready." & vbCr & vbCr & _    "Please check that the diskette is in the drive" & vbCr & _    "and that the drive's door is closed."

Here’s a slightly more concise statement, that uses a temporary separator and then replaces it with the CR character:

MsgBox Replace("Disk not ready.§§Please check that the diskette is in the " _    & "drive§and that the drive's door is closed.", "§", vbCr)

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist