|
-
May 17th, 2006, 12:40 AM
#1
Thread Starter
Fanatic Member
[Resolved] Insert Space Every X Character
Hello, I've been racking my brain out trying to figure out how to do this!
What i want to do is Insert a space every X character so like if i wanted a space every 3 characters...
"HelloEveryoneHowAreYouGoing?I'mFine!"
to
"Hel loE ver yon eHo wAr eYo Goi Ng? I'm Fin e!"
Some of the problems that i have is when i insert a space the length of the string changes and i need to count four instead of 3 for the changed bit. Also with the maths, does it effect it if the string length doesn't divide by 3 completely (such as above)?
Can you please help me come up with this code!
Last edited by Slyke; May 17th, 2006 at 01:11 AM.
-
May 17th, 2006, 12:59 AM
#2
New Member
Re: Insert Space Every X Character
VB Code:
Function StringSpace()
Dim aString As String
aString = "HelloEveryoneHowAreYouGoing?I'mFine!"
Dim output As String
output = ""
For i = 1 To Len(aString)
output = output & Mid(aString, i, 1)
If (i Mod 3 = 0) Then
output = output & " "
End If
Next
MsgBox output
End Function
-
May 17th, 2006, 01:10 AM
#3
Thread Starter
Fanatic Member
Re: Insert Space Every X Character
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|