Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InString count for specific character or string

Status
Not open for further replies.

bebop

Programmer
Oct 15, 2002
5
US
I have a string I'm passing from a form; it's a list of names seperated by commas. To parse out those individual names into seperate individual strings I need to know how many commas are in the orginal string in order to know how many loops to iterate through in my For loop.

I hope that was understandable. Is there a (easier) way to count the number of times a character/string occurs within another string?

Thanks
 
Try the Split function

Dim aryW
aryW = Split(strIn,",")
For I = 0 to UBound(aryW)
.....aryW(I)
Next

You can get a UBound = - 1 with an empty string, e.g.
aryW = Split("",",") Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top