Hi,
I have a list of comma separated items, but only have a limited line length (aprox 50 chars) to display them. If I split them at the comma, I'll end up with a long list of items. What I'd like to to is fit as many as I can on each line. In essence I'd like to loop through the string & replace the comma that's nearest to the maximum line length & replace it with a vbcrlf.
I've tried using a standard split & looping through the array, checking the length of each array item in turn & if that was less than the max length I then added it to a variable, but I'm not having much luck (the code below is an example of the sort of thing I was trying, I'm away from the script I had written so this is more pseuedo-type code). Something like:
Any help would be appreciated.
I have a list of comma separated items, but only have a limited line length (aprox 50 chars) to display them. If I split them at the comma, I'll end up with a long list of items. What I'd like to to is fit as many as I can on each line. In essence I'd like to loop through the string & replace the comma that's nearest to the maximum line length & replace it with a vbcrlf.
I've tried using a standard split & looping through the array, checking the length of each array item in turn & if that was less than the max length I then added it to a variable, but I'm not having much luck (the code below is an example of the sort of thing I was trying, I'm away from the script I had written so this is more pseuedo-type code). Something like:
Code:
if len(mylongstring) > maxlinelength Then
mylongstring_arr = split(mylongstring,",")
for x = 0 to ubound(mylongstring_arr)
If len(mylongstring_arr(x)+newstring) <= maxlinelength Then
newstring = newstring &","&mylongstring_arr(x)
Else
newstring = newstring &vbcrlf&mylongstring_arr(x)
End If
Next
End If
Any help would be appreciated.