[AccessD] Count the occurrences of each character in a string
jamesbutton at blueyonder.co.uk
Mon Sep 5 12:33:07 CDT 2022
For each character get the hex (or decimal) value
And in a dictionary create a key with that value and set it to 1,
Or if the key exists, increment it's value.
Entries are presented sorted in key order, so saves the definition count
processing, and sorting etc. needed with an array.
Note using the char() function for the key means the process is case sensitive.
<accessd-bounces+jamesbutton=blueyonder.co.uk at databaseadvisors.com> On Behalf Of
Paul Hartland via AccessD
Sent: Monday, September 5, 2022 10:05 AM
To: Access Developers discussion and problem solving
<accessd at databaseadvisors.com>
Cc: Paul Hartland <paul.hartland at googlemail.com>
Subject: Re: [AccessD] Count the occurrences of each character in a string
Off the top of my head I would use something like a two dimensional array,
then loop through the word letter by letter, if already in the array add 1
if not add it to the array with 1 as the value, so yourarray(0,0) = 'M' and
yourarray(0,1) = 1
Etc etc then do what you like with the array.
Very busy at work at moment but if you need an example let me know and will
knock one up in about 9 hours time after work
On Mon, 5 Sep 2022, 09:43 Arthur Fuller, <fuller.artful at gmail.com> wrote:
> I'm trying to figure out the best way to count the occurrences of each
> character in a string.
> Sample string: "mississipi"
> I should get back an array looking like this:
> Character Count
> m 1
> i 4
> s 4
> p 1
> Any suggestions?
> AccessD mailing list
> AccessD at databaseadvisors.com
> Website: http://www.databaseadvisors.com
AccessD mailing list
AccessD at databaseadvisors.com
More information about the AccessD