Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textarea formatting 1

Status
Not open for further replies.

dalec

Programmer
Jul 8, 2000
191
US
I'm trying to take a value from a textarea save it, and redisply it as it was typed (keeping the word wraping and formatting). I tried replace(txt_area,vbcrlf,&quot;<br>&quot;), but it only replaces the hard returns, I still get one long line of text where the textarea word wraped. I then tried replace(txt_area,vblf,&quot;<br>&quot;) incase there were just soft returns, still not any closer.

I tried changing the wrap=hard to replace the wraps to hard returns (per ms documentation), but, that did'nt work. I really want this to look like it was typed, and I know it's possible, they do it in this forum.

Thanks ahead of time for a reply.
Dale
 
I know what you mean and i've written a web board that does that. You're basically going to have to write a function to step through and replace all CHR(10) with a <BR> and then add a vbCrLf to it. Something along the lines of this but don't quote me, I'm writing this from the hip, don't feel like loading up the old funtion I wrote. =)

Code:
Function BRFilter(strTextArea)
  Dim intLoop
  Dim strChar, strTemp

  For intLoop = 1 to Len(strTextArea)
    strChar = Mid(strTextArea, intLoop, 1)

    If strChar = Chr(10) Then
      strTemp = strTemp & &quot;<BR>&quot; & vbCrLf
    Else
      strTemp = strTemp & strChar
    End If

  Next

  BRFilter = strTemp
End Function

Then, just call your function wherever you need it passing the textarea filed from your form as the parameter like so:

Code:
Response.Write BRFilter(Request.Form(&quot;your_text_area_field&quot;))

Hope this helps, I'll be watching for a response. Like I said, I just wrote this in this little text box and should work. If it doesn't might just be a simple typo or an oversight. Hope this helps. =) Ed (RoadRacer) Holguin

&quot;I Hate Computers!&quot;
 
You know, it just hit me.

I did write that routine a long time ago, and it was definitely way before I found out about the Replace function ... Hmmm ... I'm thinking, wouldn't replace still be the way to go?

Code:
Replace(txtarea, Chr(10), &quot;<BR>&quot; & vbCrLf)

In essence, that would do the same thing that my 'old' function does. Try it, it should work. Ed (RoadRacer) Holguin

&quot;I Hate Computers!&quot;
 
I think that did the trick, thank you. It turned out to be one of those deals where you want to do a simple thing and it turns in to it's own project.

Thanks again
Dale
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top