Count of Character in Text String

G

Guest

I need to determine the number of times a given character exists in a given text string. For example, how many spaces are in a formal name? I can use InStr() and then use InStr() again, using the results of the first search plus one as the start position for the nest search. I would need to keep doing this until the result is zero

But I'm hoping there is already a function out there I can use that can tell me CountInStr("Ella Fitzgerald", "l") = 3. Is there anything like that?
 
D

Dirk Goldgar

Marty2of5 said:
I need to determine the number of times a given character exists in a
given text string. For example, how many spaces are in a formal name?
I can use InStr() and then use InStr() again, using the results of
the first search plus one as the start position for the nest search.
I would need to keep doing this until the result is zero.

But I'm hoping there is already a function out there I can use that
can tell me CountInStr("Ella Fitzgerald", "l") = 3. Is there anything
like that?

It may not be the most effiicient method possible, but if you're running
Access 2000 or later you can use UBound and Split in combination to do
this:

?Ubound(Split("Ella Fitzgerald", "l"))
3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top