I am having difficulty retrieving data from a comma delimited file (.csv) I am not as familiar with VBScript as I am with other languages. Could someone please let me know how I can loop through individual items in a comma-delimited string?<br>
<br>
Thank you.
Use the Split function, return an array and loop thru the array. Example below.<br>
<br>
I imagine you are using ASP since you are reading a disk-bound CSV file... however, since you didn't say so, I wrote this with all client side VBScript. If necessary, you can easily adapt it to server-side. Have fun.<br>
<br>
<html><br>
<head><br>
<title></title><br>
<br>
<script language="VBScript"><br>
Function ParseString(strToParse, delimiter)<br>
Dim aryString<br>
aryString = Split(strToParse, delimiter)<br>
ParseString = aryString<br>
End Function<br>
</script><br>
<br>
</head><br>
<body><br>
<br>
<script language="VBScript"><br>
Dim strMyCSV<br>
strMyCSV = "this,is,cool"<br>
<br>
Dim aryParsedString<br>
aryParsedString = ParseString(strMyCSV,",")<br>
<br>
Dim i<br>
For i = 0 to Ubound(aryParsedString)<br>
Document.Write aryParsedString(i) & "<br>"<br>
Next<br>
</script><br>
<br>
<br>
<br>
</body><br>
</html>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.