Counting the number of occurrences of a character...

str = "This is ; just a test; to show; an example"

Dim arChars(255)

for n = 1 to len(str)

i = asc(mid(str,n,1))

arChars(i) = arChars(i) + 1

next

char = ";"

msgbox "The character --> " & char _

& " <-- occurs " & arChars(asc(char)) _

& " times"

PS - It's not considered polite to ask for an email reply to a newsgroup post...

--

Michael Harris

Microsoft.MVP.Scripting

--

I am looking for a way to count the number of occurrences of a character in

my vb code.

Example:

exampleStr = "This is ; just a test; to show; an example"

I would like to be able to know how many times the character ";" occurs in

the variable exampleStr. I need a numeric number to be returned. Could

Thanks for the help!!