Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing a space every 4 characters of a string

Status
Not open for further replies.

AGP

Programmer
Sep 11, 2001
97
GB
Could anyone please suggest the syntax for a function that I can use to place a space every 4 characters along a string.

i.e

"0197737654" to "0197 7376 54"

many thanks
agp.
 
' Not tested
Function Space4(strIn)
Dim strOut
Dim I
For I = 1 to Len(strIn) - 4 Step 4
strOut = strOut & Mid(strIn,1,4) & " "
Next
If I <= Len(strIn) then
strOut = strOut & Mid(strin,I)
End if
Space4 = strOut
End Function Compare Code (Text)
Generate Sort in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top