Replacing the newline characters with commas should be a one liner.
Code:
Dim strDelimited
'| VBScript uses the vbCrLf statement apposed to the \n escape sequence.
strDelimited = Replace(originalString, vbCrLf, ",")
As for spliting the string every 150 characters, it would be bst to write your own function. This one will return an array of strings.
Code:
Dim strMessage
Dim arrStrings()
Dim i
strMessage = "Some massive string"
arrStrings = SplitString(strMessage)
If IsArray(arrStrings) Then
For i = 0 To UBound(arrStrings) - 1
Response.Write(arrStrings(i) & "<br />")
Next
End If
Function SplitString(strOriginal)
Dim arr()
Dim i, intToSplit, count
intToSplit = 150
count = 0
'| Make sure the passed parameter is long enough
If Len(strOriginal) < intToSplit Then
SplitString = Nothing
End If
'| Split the string into blocks.
For i = 0 to Len(strOriginal) / intToSplit
ReDim Preserve arr(i)
arr(i) = Mid(strOriginal, count, intToSplit)
count = count + intToSplit
Next
'| Get the left over characters and put them into a new array index.
Dim intLeftOver
intLeftOver = Len(strOriginal) Mod intToSplit
If intLeftOver <> 0 Then
ReDim Preserve arr(i+1)
arr(i+1) = Right(strOriginal, intLeftOver)
End If
SplitString = arr '| Return the array.
End Function
Ok, that should work. But if it does return an error, just post here again and i will fix up my mistakes.
Regards,
Andrew Buntine.
Bookmarks