Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old June 27th, 2008, 08:26 PM
MLH
Guest
 
Posts: n/a
Default CountInstance() was a beautiful contribution by Doug Steele a few years back...

Douglas j.Steele contributed Wed, Aug 11 2004 6:15 pm.
Replace$ is not available in A97. Chuck Grimsby took care
of that with his airing of the JoeReplace FN.

My Q here today is to Doug, in regard to the use of the backslash...

Is there ever an instance where
CountInstances = (Len(ToSearch) - Len(JoeReplace(ToSearch, ToFind,
vbNullString))) \ Len(ToFind)

would return a value different than
CountInstances = (Len(ToSearch) - Len(JoeReplace(ToSearch, ToFind,
vbNullString))) / Len(ToFind)
???

If not, is the wisdom behind the backslash just to produce result that
is one of the 3 Types returned by the backslash? This one-liner, BTW,
is one of my all time favorites. The simplicity of it is staggering.
Thanks again, three years later, for your excellent contribution.
  #2  
Old June 27th, 2008, 08:26 PM
Allen Browne
Guest
 
Posts: n/a
Default Re: CountInstance() was a beautiful contribution by Doug Steele a few years back...

Yes, Doug has a good way of thinking of things.

You probably recognise / as the division operator.
The \ is the integer division operator.

You can see the difference if you open the Immediate Window (Ctrl+G) and
enter:
? (8 - 3) / 3
? (8 - 3) \ 3
The first returns 1.6 recurring. The second performs integer division, so
just returns 1.

Len() always returns integers, and the number of characters difference
should be an exact multiple of the number of characters to find, so there
should not be any difference between the result of integer division or
normal floating point division. There could be a slight performance
difference, i.e. integer division could be faster.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CRCI@NorthState.netwrote in message
news:9389449u87fvknh7bo19e6802mushm6651@4ax.com...
Quote:
Douglas j.Steele contributed Wed, Aug 11 2004 6:15 pm.
Replace$ is not available in A97. Chuck Grimsby took care
of that with his airing of the JoeReplace FN.
>
My Q here today is to Doug, in regard to the use of the backslash...
>
Is there ever an instance where
CountInstances = (Len(ToSearch) - Len(JoeReplace(ToSearch, ToFind,
vbNullString))) \ Len(ToFind)
>
would return a value different than
CountInstances = (Len(ToSearch) - Len(JoeReplace(ToSearch, ToFind,
vbNullString))) / Len(ToFind)
???
>
If not, is the wisdom behind the backslash just to produce result that
is one of the 3 Types returned by the backslash? This one-liner, BTW,
is one of my all time favorites. The simplicity of it is staggering.
Thanks again, three years later, for your excellent contribution.
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles