[web] ASP string manipulation - chr(10) every 9 characters?

Started by
3 comments, last by boolean 18 years ago
I've managed to confuse myself [sad] Say I have the following text: abcdefghijklmnopqrstuvxyz What I want to do is say: At every 9 characters, insert chr(10), then proceed for another 9 characters, then insert chr(10), and so on until it runs out of characters. The final result would look like abcdefghi chr(10) jklmnopqr chr(10) stuvxyz Any idea how I would go about doing this?
Advertisement
the easiest way would be to do something like

Dim myString

myString = "abcdefghijklmnopqrstuvxyz"

ReDim Strings(cint(Len(myString) / 9))

For SplitCount = 1 To Len(myString) Step 9
Strings(CInt(SplitCount / 9)) = Mid$(myString, SplitCount, 9)
Strings(CInt(SplitCount / 9)) = Strings(CInt(SplitCount / 9)) & Chr(10)
Next

and you can join them all back up with

joinedString = Join(Strings)

Hope that helps
So many commands I never knew existed ^_^

Cheers technomancer!
Alternately:

For I = 1 To Len(text) Step 9   result = result & Mid(text, I, 9) & chr(10)Next

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Thanks mate [smile]

This topic is closed to new replies.

Advertisement