[web] ASP string manipulation - chr(10) every 9 characters?
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?
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement