Forcing text out to wrap at 72 characters.

Results 1 to 2 of 2

Thread: Forcing text out to wrap at 72 characters.

  1. #1
    Join Date
    Dec 1969

    Default Forcing text out to wrap at 72 characters.

    I&#039;ve written a page that pulls information from our database and spits it out in both HTML format and plain text. This is for one of our people in-house who sends out emails to our customers. The page allows him to easily cut and paste the HTML or the plain text into the body of his email template and shoot it off to the clients.<BR><BR>While the HTML portion works great, I&#039;m not quite experienced enough to know exactly how to go about formatting the plain text so it wraps for him at 72 characters per line. Right now, he copies and pastes the plain text, but then he has to re-modify the text so that each line wraps at this limit. Ideally I&#039;d like to automatically do this for him so he doesn&#039;t have to spend the additional formatting time.<BR><BR>Any suggestions on how to proceed with this? Could I somehow build an array split off at every 72nd character (or whatever word doesn&#039;t exceed the total character limit per line)? Or is there another way I&#039;m not seeing?

  2. #2
    Join Date
    Dec 1969

    Default RE: Forcing text out to wrap at 72 characters.

    There are probably multiple ways to do this; this is just one way. Allow the user to insert the information in any way they like. Store it in the database the same way. This is useful in case you want to change formatting later. For the formatting of the email, create a CONST variable called something like MAX_COLS which will hold 72 (CONST MAX_COLS = 72).<BR><BR>When formatting your email, loop through the text using a for loop from 1 to UBound(text) and use Mid. When you get to MAX_COLS, insert a break in the email (vbCrLf or vbLf). Ideally you could MOD 72 and insert breaks that way. You will probably have to do some checking for users&#039; hard return, where you will then reset your count.<BR><BR>Play around with it. Hope this helps even though it may be a little late.<BR><BR>Frijoles<BR>#asp on efnet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts