|
-
October 3rd, 2001, 08:47 AM
#1
Count character occurances
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
-
October 3rd, 2001, 09:44 AM
#2
Re: Count character occurances
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
-
October 3rd, 2001, 11:07 AM
#3
Re: Count character occurances
Well what could I expect.
Thanks, Jenda
-
October 3rd, 2001, 11:23 AM
#4
Re: Count character occurances
Try the Split function. Ex rivate Sub Command1_Click()
Dim sText as string
sText = "abc3456copchj"
MsgBox UBound(Split(sText, "c"))
End Sub
-
October 3rd, 2001, 03:40 PM
#5
Re: Count character occurances
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!
----------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|