[AccessD] Count the occurrences of each character in a string
Arthur Fuller
fuller.artful at gmail.com
Tue Sep 6 10:11:49 CDT 2022
Thanks, Jim.
I'll give that approach a try too just to learn something new about VBA
dictionaries.
On Mon, Sep 5, 2022 at 1:33 PM James Button via AccessD <
accessd at databaseadvisors.com> wrote:
> VBA dictionary
> 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.
>
> JimB
>
> -----Original Message-----
> From: AccessD
> <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
>
> Paul
>
> Paul
>
> 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?
> >
> > --
> > Arthur
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
--
Arthur
More information about the AccessD
mailing list