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:
Public Function CountLetters(w$, ltr$) As Integer Dim i As Integer, c$, Count As Integer For i = 1 To Len(w$) c$ = Mid$(w$, i, 1) If c$ = ltr$ Then Count = Count + 1 Next i CountLetters = Count End Function




Reply With Quote