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

replacing chars in a string 3

Status
Not open for further replies.

raupe

Technical User
Jan 18, 2005
1
DE
Hi all!
Hope you can help me with this:
In the past I had a macro that read a string from screen that maybe had some blanks at the beginning or at the end. I eliminated these blanks with the "trim" command. Now there are underscores ("_") instead of blanks and "trim" does not work any more. Is there any possibility to replace all underscores with blanks in the whole string?
Thanks for your help
 
Sure, I use a loop:

Do While Instr(MyString,"_")<> 0
MyString = Left(MyString,Instr(MyString,"_")-1) & mid(MyString,Instr(MyString,"_")+1,len(MyString))
Loop

Obviously you can use any character in the code to remove it, or change it to a space, or use a variable and put it in a function.

calculus
 
Here's the Function I use:

Function strip(changeme as string,stripme as string) as string
pos=instr(changeme,stripme)
while pos<>0
changeme=left(changeme,pos-1)+right(changeme,len(changeme)-pos)
pos=instr(changeme,stripme)
wend
strip=changeme
End Function

Shrek if you see this the credits all yours buddy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top