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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting strings

Status
Not open for further replies.

demchak

IS-IT--Management
Jun 29, 2001
36
US
I have a text data field that I need to reformat. I need to take a 6 char text field and insert an "-" between the 5th and 6 char.

ex becomes

123456 12345-6
222230 22223-0

I was just looking for the easiest way to accomplish this.

Thanks,
WH
 
If the string length is always 6 char then use the Left(string,5) and Right(string) commands.
Ex: temp = Left(string,5) & "-" & right(string,1)
If the length will vary then use a for next loop to cycle through it like this.
Ex: for x = 1 to len(string)-1: temp = temp & mid(string,x,1): next x : temp = temp & "-" & right(string,1)

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top