Jan 22, 2004 #1 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!
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!
Jan 22, 2004 2 #2 MisterNiceGuy MIS Nov 4, 2002 103 US 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 Upvote 0 Downvote
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