Trim() vs Trim$(), etc 
Author Message
 Trim() vs Trim$(), etc

Quote:

> Hi all,

> Is Trim() or Trim$() faster/better/preferred? Shall I always use the
> functions that return the exact datatypes? Thanks.

Unless you can motivate the use of Variants, use the exact
data types. The use of exact (read explicit) data types brings
clarity to your code when reading it three weeks later.

VB does a lot of data type conversions behind the scenes when
using the untyped versions. The code
  S$ = Trim(A$)
generates code such as (in pseudo-code)
  S$ = to_string(Trim$(to_string(A$)))

There really is only one version of these functions, and that
is the Trim$(). Trim() is only a wrapper around it.

As I have said earlier: Be specific. Write what you mean. Only
then others can understand what you ment.

/Peter
--
Peter Lindgren                        Bachelor of Computer Engineering
Norrsken Konsult, M?lndal, Sweden                 +46 - (0)31 27 17 09



Wed, 23 Aug 2000 03:00:00 GMT  
 Trim() vs Trim$(), etc

Yes, there is a preference... Trim$() will provide slightly better
performance, and the same applies for Left$(),Right$(), and Mid$().  Making
it an explicit return lets VB away with a little less thinking.  So I
think....

Tom Coyle


Quote:
> Hi all,

> Is Trim() or Trim$() faster/better/preferred? Shall I always use the
> functions that return the exact datatypes? Thanks.

> Rgds,
> Kevin



Sat, 26 Aug 2000 03:00:00 GMT  
 Trim() vs Trim$(), etc

Tom

I agree, but careful you don't miss the point of having the two
functions. If you're using Variants, you must use Trim() and if you're
using Strings, you must use Trim$(). The real choice is not whether to
use Trim() or Trim$(), but whether to use Variants or Strings.

There is a considerable argument for using Variants throughout a system.
I don't happen to subscribe to it.

Regards
{*filter*}



Quote:
>Yes, there is a preference... Trim$() will provide slightly better
>performance, and the same applies for Left$(),Right$(), and Mid$().
Making
>it an explicit return lets VB away with a little less thinking.  So I
>think....

>Tom Coyle




Quote:
>> Hi all,

>> Is Trim() or Trim$() faster/better/preferred? Shall I always use the
>> functions that return the exact datatypes? Thanks.

>> Rgds,
>> Kevin



Sat, 26 Aug 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Trim vs Trim$

2. Difference between trim and trim$

3. Trim not trimming?

4. Equivalent functionality to trim - but with a differenct character set trimmed

5. Trim Function

6. cross trim function and replace command

7. Right trim in table entries

8. Cant fix Trim error

9. Trim, Len, Mid Errors

10. Trim and DateAdd functions No Longer Working

11. Trim() function in query can't be run in Access Runtime Environment

12. Trim leading zeros from string

 

 
Powered by phpBB® Forum Software