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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie: Counting within a string 2

Status
Not open for further replies.

ncar35b

Technical User
Jan 10, 2003
55
US
Hi, I can't seem to figure out how to count within a string. For example, I want to use VBScript to count how many commas are in the following string:

strPlantID = "TES328,UYW991,NNB210,WUU322,POU098"

Thanks for any help!

 
The following code shows how to get a count of the commas as well as how to us an array to iterate through a comma delimited list of items.

strPlantID = "TES328,UYW991,NNB210,WUU322,POU098"
PlantArray=Split(StrPlantID,",")
CountofDelimiter=Ubound(Plantarray)

'Return a count of the delimiters, in this case the number of commas.
Msgbox "There are " & CountofDelimiter &" commas"

'Return the individual items from the array we created.
For Each item In plantarray
msgbox item
Next

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top