Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Jul 30, 1999

Repeat Performance

A simple loop through your main string lets you count the occurrences of a specified character or string. This function is useful for determining if enough commas appear in your comma-delimited string:

 
Function Tally(sText As String, sFind As String) As Long
	Dim lFind As Long
	Dim lLast As Long

	Do
		lFind = InStr(lLast + 1, sText, sFind)
		If lFind Then
			lLast = lFind
			Tally = Tally + 1
		End If
	Loop Until lFind = 0
End Function
Jeffrey Renton
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date