VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Returns the number of times a given string or character repeats in the whole string. Example: thisS

by Edgar C. (2 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Wed 12th January 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Returns the number of times a given string or character repeats in the whole string. Example: thisString = "This code is an excellent code."

Rate Returns the number of times a given string or character repeats in the whole string. Example: thisS



On Error GoTo finish
Dim myPos As Integer
Dim strCounter As Integer

strCounter = 0
    Do
        myPos = InStr(myPos + 1, thisString, thisStr)
        If myPos <> 0 Then
            strCounter = strCounter + 1
            myPos = myPos + Len(thisStr)
        End If
    Loop While myPos <> 0

numTimesCharRepeats = strCounter

Exit Function
finish:
If Err <> 0 Then
    Err = 0
    numTimesCharRepeats = 0
    Exit Function
End If

End Function



Download this snippet    Add to My Saved Code

Returns the number of times a given string or character repeats in the whole string. Example: thisS Comments

No comments have been posted about Returns the number of times a given string or character repeats in the whole string. Example: thisS. Why not be the first to post a comment about Returns the number of times a given string or character repeats in the whole string. Example: thisS.

Post your comment

Subject:
Message:
0/1000 characters