473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

CountInstance() was a beautiful contribution by Doug Steele a few years back...

MLH
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.
Jun 27 '08 #1
1 1100
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" <CR**@NorthState.netwrote in message
news:93********************************@4ax.com...
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.
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: israel | last post by:
The current DDJ ( at least the latest that our antipodean newsstands have ) has an interesting interview with Guy Steele. He contributed to Scheme, Lisp , Java and did the first port of Tex.
38
by: vinjvinj | last post by:
I haven't used an IDE in a long time but gave wing ide a try because I wanted the same development platform on Linux and Windows. I'm currently using Ultraedit and it works fine but needed...
3
by: Max | last post by:
I have a friend who has been programming in C for many years, and he is a great fan of the language. However, he (and I) are about to start a python course, and he has been asking me a lot of...
15
by: Francach | last post by:
Hi, I'm trying to use the Beautiful Soup package to parse through the "bookmarks.html" file which Firefox exports all your bookmarks into. I've been struggling with the documentation trying to...
1
by: baseballswim123 | last post by:
Friend, I'm always looking for good and intelligent individuals like you to visit my website, www.ChezBrandon.com , and it has pictures of beautiful women, information about aged clones, and a...
3
by: cjl | last post by:
I am learning python and beautiful soup, and I'm stuck. A web page has a table that contains data I would like to scrape. The table has a unique class, so I can use: soup.find("table",...
2
by: kj | last post by:
My favorite book on C, by far, is Harbison and Steele's "C: A Reference Manual." (In fact, it is my all-time favorite computer language reference book, irrespective of language.) Even though it...
8
by: js | last post by:
Hi, Have you ever seen Beautiful Python code? Zope? Django? Python standard lib? or else? Please tell me what code you think it's stunning.
3
by: sophie_newbie | last post by:
Hi, I'm running a python cgi script on a frontend web server and I want it to spawn another script (that takes a long time to run) on a backend number crunching server thats connected to the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.