Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
This function will return the number of times one ...
Author:
Bhagyesh Trivedi
Submitted:
3/18/2003
Version:
VB5
Compatibility:
VB5, VB6
Category:
String Manipulation
Views:
10416
This function will return the number of times one string is found in another string.
Declarations:
'none
Code:
Public Function getCountOf(OriginalString As String, StringToLookFor As String) As Integer On Error GoTo Err_Init Dim i As Integer getCountOf = 0 'initilaise the return value as 0 i = 1 ' set it as the first While i <> 0 i = InStr(i, OriginalString, StringToLookFor) ' set it to the next If i <> 0 Then ' if found then i = i + 1 ' set it to the found place +1 getCountOf = getCountOf + 1 'increment the count by one End If Wend Exit Function Err_Init: HandleError "ModMain", "getCountOf", Err.Number, Err.Description End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement