Thomas’ Developer Blog

May 4, 2008

Inline Trimming in VBScript

Filed under:, vbscript — Tags: , , , , — sanzon @ 9:09 pm

This post continues from:

In the last post I went over how to remove linebreaks from the begining and end of a multiline string and at the same time forcing paragraph style post with double linebreaks.

Now in this post I’m going to take it another step with inlinetrimming.  What this means is if you have a post like:

“Hi mom,

   Today there was a    …..”

The problem is that big dent at the begining and end of the paragraph.  Now in HTML this normally will turn out to a single line space, unless you preserve spacing by converting chrW(32) into  

To remove this excess we simple use a simular method for our inline trimming method.
   Public Function InlineTrim(ByVal mySrc As String) As String
    If mySrc = “” Then
     return nothing
     exit function
    End If

    Dim myStr As String = mySrc

    Dim myChar As String = chrW(10) & chrW(32)

    myStr = Replace(myStr,chrW(13),””)

    do while Regex.IsMatch(myStr,”\n “)
     myStr = Replace(myStr,myChar,chrW(10))
    do while Regex.IsMatch(myStr,” \n”)
     myStr = Replace(myStr,StrReverse(myChar),chrW(10))

    return myStr
   End Function

 This function is very simple.  First you go ahead and remove all returns in the string and than search for instances of “\n ” and ” \n” and return it as “\n” and continue to repeat this until all spaces are remove.  The ending result is a nice clean block text format with not indents at the begining or end.

Anyway be expecting alot of these post coming up as I redo my class library on my site… the horror of string formating X_x;

well happy coding!



  1. It’s impressive that you are getting thoughts from this article as well as
    from our discussion made at this place.

    Comment by how to configure best cable cable modem for xbox — August 23, 2014 @ 11:50 am

  2. Hello to all, the contents existing at this website are
    in fact amazing for people experience, well, keep up the good work fellows.

    Comment by how to configure best buying a cable modem for comcast internet — September 7, 2014 @ 3:04 am

  3. I like what you guys tend to be up too. This sort of clever work
    and reporting! Keep up the awesome works guys I’ve added you guys to our blogroll.

    Comment by how to configure best where to buy modem for comcast — September 8, 2014 @ 9:48 am

  4. Hi friends, how is everything, and what you want to say on the topic of this paragraph, in my view its truly awesome for me.

    Comment by how to configure best buy cable modem for comcast — September 21, 2014 @ 6:48 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: