Replace VbCrLf in TextArea

73265 Users read it.
by Marcellino Bommezijn (September 26, 2001)
This is a simple tutorial on how to replace VbCrLf in a textarea by <br>, so that you can format the input when displayed. 

User Rating (92 votes)
10 reviews available | Read the reviews »
Product:UltraDev 4
Server Model:ASP VBScript

This tutorial will show how to replace VbCrLf with <br>, so that the input of a textarea gets formatted for display.

When making a insert or update in Ultradev/MX you just have to make a small insert to make this work.

Find the code that is commented with 'create the sql insert statement' or 'create the sql update statement'.

In this code find (Ultradev):

Else
FormVal = Delim + FormVal + Delim
End If
End If

FormVal = Replace(FormVal,vbCrLf,"<br>")

If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if

In this code find (MX):

Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If

MM_formVal = Replace(MM_formVal,vbCrLf,"<br>")

If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If

Insert the red marked replace command and the flat text in a textarea will formatted where the user has made a Return.

This is very handy when using just a form to maintain for example a news admin-tool.

That's it !

 

 

Marcellino Bommezijn

Marcellino BommezijnMarcellino Bommezijn is one of the managers at dmxzone.com. He is a contributor on the tutorials section.

Owner of Senzes Media (http://www.activecontent.nl) which provides professional services and web applications for mid-sized companies.

ActiveContent CMS is the ASP.NET Content Management solution that is used for building professional and rich-featured websites.

See All Postings From Marcellino Bommezijn >>

User Reviews

Total of 10 reviews
RE: RE: how to do the opposite?
Written by steve powell on February 7, 2005

Remember that the Replace function has more arguments that will greatly simplify your code by allowing case INSensiTive searching strTmp1 = Replace(CStr(strHTM),'<br>', vbCrLf, 1,-1, 1)strTmp = Replace(strTmp1,'<tr>', vbCrLf, 1,-1, ...

RE: RE: RE: RE: how to do the opposite?
Written by hans grimm on June 27, 2003

Yes! I have discovered the way to do it all serverside and show the formfield with the text already formatted: step 1: put the script above the <html>-tags, like this: <%function RemoveHTML(strHTM) dim strTmp, strTmp1, i, lngLen, ...

RE: RE: RE: how to do the opposite?
Written by Tim Bednar on March 17, 2003

I figured it out. The VBScript does not work on the MAC because it is client side. So I use this instead... <%Dim strBodystrBody = rsEntry.Fields.Item('Body')%><textarea name='txtBody'><%=Replace ...

RE: RE: how to do the opposite?
Written by Tim Bednar on March 17, 2003

This little trick works great for Win IE, but does not work on my Mac IE? Any suggestions?

Great little tutorial
Written by Ralf Fredriksson on December 17, 2002

I´ve searched this place for this functon and couldn´t find it so I wrote in the MX forum and asked for this. No answers. But I found this tutorial by accident and it worked great. Thanks

RE: RE: RE: how to do the opposite?
Written by hans grimm on March 4, 2002

one other little thing I found out: if you do not want all tags to be stripped (such as <b> or <a>, etc.), in the script, replace 'If charOne='<' Then' by 'If charOne='' Then', and 'If charOne = '>' Then' by 'If charOne = '' Then'. ...

RE: RE: how to do the opposite?
Written by hans grimm on February 13, 2002

note: 'naam.TextArea' is to be replaced by the name of your textarea...

RE: how to do the opposite?
Written by hans grimm on February 13, 2002

hello, I'm replying to my own post because I've found it! see below: this between <Head> </Head>:-----------------------------------------------------------------------<SCRIPT language='VBScript'><!--function RemoveHTML(strHTM) ...

Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency