473,385 Members | 2,004 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,385 software developers and data experts.

Access 97 and counting the occurrences in a string

Besides doing a loop is there a command that will give the number of
occurreneces of a chr in a string?

The only way I can think of is to do a while loop and count variable.

thanks for info

Jerry
Nov 13 '05 #1
3 2404
sparks wrote:
Besides doing a loop is there a command that will give the number of
occurreneces of a chr in a string?

The only way I can think of is to do a while loop and count variable.

thanks for info

Jerry


We all have utility functions for stuff that comes up like this over and
over. Just put your loop code into a function and then use that wherever
you need to do this.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2
yes that is what I did...someone was saying that access2003 had this
built in with the new vb.net code.
just checking

jerry

On Tue, 13 Sep 2005 12:58:25 GMT, "Rick Brandt"
<ri*********@hotmail.com> wrote:
sparks wrote:
Besides doing a loop is there a command that will give the number of
occurreneces of a chr in a string?

The only way I can think of is to do a while loop and count variable.

thanks for info

Jerry


We all have utility functions for stuff that comes up like this over and
over. Just put your loop code into a function and then use that wherever
you need to do this.


Nov 13 '05 #3

"sparks" <js******@swbell.net> wrote in message
news:8l********************************@4ax.com...
yes that is what I did...someone was saying that access2003 had this
built in with the new vb.net code.
just checking

jerry

On Tue, 13 Sep 2005 12:58:25 GMT, "Rick Brandt"
<ri*********@hotmail.com> wrote:
sparks wrote:
Besides doing a loop is there a command that will give the number of
occurreneces of a chr in a string?

The only way I can think of is to do a while loop and count variable.

thanks for info

Jerry


We all have utility functions for stuff that comes up like this over and
over. Just put your loop code into a function and then use that wherever
you need to do this.

In versions later than A97, you have a Replace function which makes no
looping necessary. If you wanted to use this code in A97, you would just
have to write the Replace function yourself.

Public Function CountSubstrings(MainString As String, _
SubString As String, _
Optional CaseSensitive _
As Boolean = False) As Long

' Function returns zero if SubString=""
If Len(SubString) < 1 Then Exit Function

If CaseSensitive Then
CountSubstrings = (Len(MainString) - _
Len(Replace(MainString, SubString, _
"", , , vbBinaryCompare))) \ Len(SubString)
Else
CountSubstrings = (Len(MainString) - _
Len(Replace(MainString, SubString, _
"", , , vbTextCompare))) \ Len(SubString)
End If

End Function

Nov 13 '05 #4

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

Similar topics

1
by: francescomoi | last post by:
Hi. I'm using 'strpos', but wonder whether this function exists: find_string($haystack, $needle) which returns an array with all the numeric positions of the occurrences of needle in the...
4
by: Travers Naran | last post by:
Here's the basic idea. I have a dictionary of substrings (the substrings stored as keys). I have a list of strings. I want to find out, for each word in the dictionary, how many times the...
8
by: DrNoose | last post by:
Hi! I'm writing a program that is supposed to read a line of input, count the words and the number of occurrences of each letter. Then it should prints the number of occurrences of each letter...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: MLH | last post by:
I have a block of text with about 19,000 characters - alphanumeric, punctuation, hard returns, etc... I would like to count the number of periods ( Chr$(46) ) appearing in the document. Whats a...
8
by: John | last post by:
I have two strings S1 and S2. I want to know how many times S2 occurs inside S1. For instance if S1 = "AAAA" and S2 = "AA" then the count is 3. Is there an easy way to do this in python?...
11
by: b_or_not2c | last post by:
Hi, I am trying to count the number of substrings within a string. I am fairly new to programming and need a headstart. Any info would be appreciated. Thanks, A
3
by: newstips6706 | last post by:
The Art of Counting TIME -------------------------------------------------------------------------------- As the research done on the paper titled: "The Number '1'", which yielded the...
3
by: Beeteh | last post by:
Hello everybody! I'm a so-called newbie at programming in C/C++ and I'm currently working on a poject that searches for a particular string in a file. The user enters the string he/she is searching...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.