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!

Replacing last character in a string

Status
Not open for further replies.

mdr227

Programmer
Nov 17, 2000
114
US
What would the coding be to replace the last character in a string?

For example, if my variable varString = 'This is a test,'
and I want to replace the comma at the end with nothing so the result is 'This is a test' how would I do that?
 
Something like this:

Replace(varString,Right(varString,1),"")

-DNG
 
if it is the comma that you want to replace always...then you can simply say

Replace(varString,",","")

-DNG
 
oops, i think my first suggestion is wrong...try this instead...

strlen=len(varString)

newstr=Left(varString,(strlen-1))

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top