Is there a function or something to count the number of occurances of a specific character in a string?
I can implement it using a loop and InStr(), but a builtin would definitely be quicker.
I'm using VB 6.0.
Thanks, Jenda
Printable View
Is there a function or something to count the number of occurances of a specific character in a string?
I can implement it using a loop and InStr(), but a builtin would definitely be quicker.
I'm using VB 6.0.
Thanks, Jenda
I'm affraid there's no such function available in VB... so you will have to do it using Instr.
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Well what could I expect.
Thanks, Jenda
Try the Split function. Ex:private Sub Command1_Click()
Dim sText as string
sText = "abc3456copchj"
MsgBox UBound(Split(sText, "c"))
End Sub
Funny there is a Replace function but not the function you need...
Dim str as string
Dim len1 as Integer
str = "fds11fdgfdgd343111g"
len1 = len(str)
str = Replace$(str, "1", vbNullString)
MsgBox len1 - len(str)
----------
The @host is everywhere!
----------