ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Trim and Application.worksheetfunction.Trim (https://www.excelbanter.com/excel-programming/321139-vba-trim-application-worksheetfunction-trim.html)

Hari Prasadh

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



JE McGimpsey

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.


Tom Ogilvy

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





Hari Prasadh

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








All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com