Is there a VB function to return the number of characters A, in a string B?
For example I want to know how many times the letter "a" occurs in the word "aardwolf", the function should return 2.

Right now I'm doing the following slow code. I need something faster.

code Code:
  1. Public Function CountLetters(w$, ltr$) As Integer
  2.     Dim i As Integer, c$, Count As Integer
  3.     For i = 1 To Len(w$)
  4.         c$ = Mid$(w$, i, 1)
  5.         If c$ = ltr$ Then Count = Count + 1
  6.     Next i
  7.     CountLetters = Count
  8. End Function