Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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 ,
"Hari Prasadh" 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default 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" wrote in message
...
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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trim Jim Excel Discussion (Misc queries) 4 February 2nd 10 03:00 PM
Trim Fareez Excel Worksheet Functions 2 January 13th 10 08:13 AM
Application.Trim with VBA Jeff Excel Discussion (Misc queries) 2 April 24th 06 09:18 PM
TRIM? Cthulhu Excel Worksheet Functions 10 February 10th 05 09:36 PM
Trim like worksheet Trim Bob Phillips[_5_] Excel Programming 0 August 20th 03 07:10 PM


All times are GMT +1. The time now is 07:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"