How many times a character occurs in a string.
For example: I have a string "1.2.3.4" and I want a function to return the value 3 because "." occurs 3 times in the string.
Does anyone have such a function?
Printable View
How many times a character occurs in a string.
For example: I have a string "1.2.3.4" and I want a function to return the value 3 because "." occurs 3 times in the string.
Does anyone have such a function?
Code:Const TEXT = "1.2.3.4"
Const CHAR = "."
Dim intCount As Integer
Dim intIndex As Integer
For intIndex = 1 To Len(TEXT)
If Mid$(TEXT, intIndex, 1) = CHAR Then
intCount = intCount + 1
End If
Next
------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"
If you have VB6:
dim text as string
dim ans as integer
text = "1.2.3.4"
ans = Len(text) - Len(Replace(text, ".", ""))
HTH
------------------
LM Ginn