+ Reply to Thread
Results 1 to 4 of 4

VBA Trim and Application.worksheetfunction.Trim

  1. #1
    Hari Prasadh
    Guest

    VBA Trim and Application.worksheetfunction.Trim

    Hi,

    Not really a doubt...

    Just curious as to why Microsoft has made 2 functions available in VBA, with
    same name but with different results. VBA trim is concerned only with
    leading spaces, while App.Wkshfunction.trim removes all spaces (except a
    single space between words).

    If the end results are different then, shouldnt the name of the functions be
    different.

    --
    Thanks a lot,
    Hari
    India



  2. #2
    JE McGimpsey
    Guest

    Re: VBA Trim and Application.worksheetfunction.Trim

    Apples and Oranges.

    Trim() is a VBA function. It exists in any VBA environment (including
    VB).

    The XL TRIM() function, exposed in VBA through
    Application.WorksheetFunction.Trim(), is independent of (and preceded)
    VBA.

    In cases where a VBA function does the same thing as an application
    function, the application function isn't exposed, e.g., DATE() isn't
    exposed since DateSerial() performs the same function. Since TRIM() and
    Trim behave differently, TRIM is exposed.

    Similarly, Application.WorksheetFunction.Round() is exposed since
    ROUND() and VBA's Round() return different results when the least
    significant digit is 5.


    In article <[email protected]>,
    "Hari Prasadh" <[email protected]> wrote:

    > Not really a doubt...
    >
    > Just curious as to why Microsoft has made 2 functions available in VBA, with
    > same name but with different results. VBA trim is concerned only with
    > leading spaces, while App.Wkshfunction.trim removes all spaces (except a
    > single space between words).
    >
    > If the end results are different then, shouldnt the name of the functions be
    > different.


  3. #3
    Tom Ogilvy
    Guest

    Re: VBA Trim and Application.worksheetfunction.Trim

    Excel and VBA are two separate products that have been brought together.
    The trim function or equivalent is found in most programming languages and
    functions pretty much as VBA's trim function. Excel, developed as a
    separate product, had a trim function before the interface to VBA was
    introduced in xl5.

    Round, introduced in VBA6, works differently than the round function found
    in Excel. I am sure there are others that don't come immediately to mind.
    Replace (VBA) and Substitute (Excel) work very similarly, but don't have the
    same name. I think you will just have to learn the distinctions.

    --
    Regards,
    Tom Ogilvy



    "Hari Prasadh" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > Not really a doubt...
    >
    > Just curious as to why Microsoft has made 2 functions available in VBA,

    with
    > same name but with different results. VBA trim is concerned only with
    > leading spaces, while App.Wkshfunction.trim removes all spaces (except a
    > single space between words).
    >
    > If the end results are different then, shouldnt the name of the functions

    be
    > different.
    >
    > --
    > Thanks a lot,
    > Hari
    > India
    >
    >




  4. #4
    Hari Prasadh
    Guest

    Re: VBA Trim and Application.worksheetfunction.Trim

    Hi JE M and Tom,

    Thanx a lot for the nice explanations you have given to me.

    Highly informative.

    Would remain wary of Round as well.
    --
    Regards,
    Hari
    India

    "Tom Ogilvy" <[email protected]> wrote in message
    news:OvMS#[email protected]...
    > Excel and VBA are two separate products that have been brought together.
    > The trim function or equivalent is found in most programming languages and
    > functions pretty much as VBA's trim function. Excel, developed as a
    > separate product, had a trim function before the interface to VBA was
    > introduced in xl5.
    >
    > Round, introduced in VBA6, works differently than the round function found
    > in Excel. I am sure there are others that don't come immediately to mind.
    > Replace (VBA) and Substitute (Excel) work very similarly, but don't have

    the
    > same name. I think you will just have to learn the distinctions.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    > "Hari Prasadh" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > Not really a doubt...
    > >
    > > Just curious as to why Microsoft has made 2 functions available in VBA,

    > with
    > > same name but with different results. VBA trim is concerned only with
    > > leading spaces, while App.Wkshfunction.trim removes all spaces (except a
    > > single space between words).
    > >
    > > If the end results are different then, shouldnt the name of the

    functions
    > be
    > > different.
    > >
    > > --
    > > Thanks a lot,
    > > Hari
    > > India
    > >
    > >

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1