Hello All,

As the title..
Does any one know how to find how many specific character in a text?

Best Regard
Eko.

Recommended Answers

Try This :
Text1 is filled by any text or words
Text2 is filled by char to find.

Private Sub Command1_Click()
    Dim CharCount, i As Integer
    CharCount = 0
    For i = 0 To Len(Text1.Text)
        Text1.SetFocus
        Text1.SelStart = i
        Text1.SelLength = 1
        If Text1.SelText = Text2.Text Then …
Jump to Post

All 4 Replies

Try This :
Text1 is filled by any text or words
Text2 is filled by char to find.

Private Sub Command1_Click()
    Dim CharCount, i As Integer
    CharCount = 0
    For i = 0 To Len(Text1.Text)
        Text1.SetFocus
        Text1.SelStart = i
        Text1.SelLength = 1
        If Text1.SelText = Text2.Text Then 
            CharCount = CharCount + 1 sesuai
        End If
    Next
    MsgBox "You have " & CharCount & " Character " & Text2.Text
End Sub
commented: Good job +2

Working like a charm..
Thank you for helping sir.

Also this thread already solved.
Thanks once again.

You're Welcome.
Happy Coding

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.