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

string problem

Status
Not open for further replies.

JazzLeg

Programmer
Aug 22, 2002
63
GB
Hi,

I would like to remove the 5th and 6th characters from a string.

Therefore "helloo" to "hell"

How can I do this?

Thanks
 
If the original string is always going to be 6 characters then you can do this simply by using:
Code:
strString = "helloo"
strString = Left(strString,4)

If your string will be longer than 6 characters and you wish to remover characters 5 and 6 - eg) "helloohelloo" to become "hellhelloo" then you need to do the following:
Code:
strString = "helloohelloo"
strLeft = Left(strString,4)
strRight = Right(strString,Len(strString-6))

strString = strLeft & strRight
Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Another way to do this is to use the MID function.


myStr = "helloohelloo"
editStr = MID(myStr,1,4) + MID(myStr,7)

I don't know if this is any better than then FesterSXS's answer - it just gives you another option...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top