\\\
Dim n As Integer = CountOccurances(..., ","c)
..
..
..
Private Function CountOccurances( _
ByVal Text As String, _
ByVal Character As Char _
) As Integer
Dim Count As Integer
For Each c As Char In Text
If c = Character Then
Count += 1
End If
Next c
Return Count
End Function
///
This was the best result in a test I did last year when it is about a char.
This code was supplied by Jay B. Harlow
Public Function test5(ByVal input As String, ByVal _
delimiter As Char) As Integer
Dim count, index As Integer
index = input.IndexOf(delimiter)
Do Until index < 0
count += 1
index = input.IndexOf(delimiter, index + 1)
Loop
Return count
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.