Sign in to follow this  

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

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
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)

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this