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!

text manip 2

Status
Not open for further replies.

52

Programmer
Jan 23, 2002
30
US
I'm creating a keyword search and have been able to search fields with a one-word search. Now I'm trying to have multiple word searches.

Anyway, I'm trying to manipulate a piece of text so that all spaces will be changed to "*"

So this sentence will be:
So*this*sentence*will*be:

Thanks, in advance.
 
To create such a function, you could run a loop from 1 to whatever and increment the counter by 1 each time throught the loop. Use the value of the counter in the Mid() function to select a position in the string to read that particular character. If that character is a space, concatinate the astrisk, otherwise concatinate the character.
 
Current version of VBA has the 'Replace' function... here's a simple function:

Function ReplaceChar(TargetString, CharToReplace, ReplacementChar)

ReplaceChar = Replace(TargetString, CharToReplace, ReplacementChar)

End Function

If you call it like this:

ReplaceChar("This is the incoming string", " ","*")

it returns this:

This*is*the*incoming*string
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top