• Advertisement
Sign in to follow this  

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

This topic is 4347 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement