Re: How do you remove all the symbols?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



The fact the msgbox shows "hidden message oxford st" shows the function is
working.

The function as it stands does not change the original string, it returns a
new changed string. I wrote that way so you can use it as a UDF, eg formula
in a cell, say B1

=RepChars(A1)

If you are only using macros and want to change your original string you can
either work with the original function like this -

Sub Test2()
Dim sOld As String
Dim sNew As String

sOld = "!#£$abc!£$ def)(&*-"
sNew = RepChars(sOld, True, True)
sOld = sNew

MsgBox sOld

End Sub

Or you can dispense with sOld and simply

sOld= RepChars(sOld, True, True)

A different approach is to amend the function to change the original string
within the function. Start by copying the entire function and give it a new
name, eg RepString. Remove "As String" at the end of the function line. Then
change the following two lines

' sTmp = StrConv(bArr, vbUnicode)
' RepString= Replace(sTmp, "#", "")

strIn = StrConv(bArr, vbUnicode)
strIn = Replace(strIn, "#", "")

Also comment or delete the line after the error handler,
' RepString= "error"
While testing also comment the line
On Error Goto errH

To call the function and directly change your string try something like

Sub Test3()
Dim s As String
s = "!#£$abc!£$ def)(&*-"

RepString s, True, True

MsgBox s

End Sub


But remember you can't use this version as a UDF in worksheet formulas.

Hope you understood the purpose of the arguments True, True in the example.
This first instructs remove all the misc characters, the second True/False
to remove the numbers. You would want to pass at least one True or the
function will do nothing.

Regards,
Peter


If you want to change the original string to the new string there are
different ways
"elaine" <elaine216@xxxxxxxxx> wrote in message
news:1147437324.564954.101200@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hi pete,
the first code you posted wasnt working... and I dont really understand
how it works.. and after i run the code, a message box pops up with all
the symbols and 123 oxford st, with hidden message oxford st. I guess
its just show that cos its in the code... but it didnt delete any of my
sumbols or numbers in the column...



.



Relevant Pages

  • Re: Warning to newbies
    ... // Replace target by replacement string in master string ... struct TYPsegmentstruct * ptrSegmentStruct; ... You start with ptrIndex1. ... or to the end of the original string. ...
    (comp.lang.c)
  • Re: Splitting a large string variable into lines <= 70 chars
    ... I kinda agree with you that perhaps the string search methods and functions like InStrRev and LastIndexOf will not be the fastest way. ... Wait till they grumble it's slow and then throw in a faster routine and your a hero again! ... All he'd done was reduce the number of iterations his code spent in the wait loops. ... Instead, do not modify the original string at all during the loop, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Comment on trim string function please
    ... If the char type on any machine ... How do you think the characters wound up in a string in the first ... original string: ...
    (comp.lang.c)
  • Re: strtok ( ) help
    ... >>> string between calls to strtok() its copy would no longer match. ... >> operation changed the original string between calls to strtokits ... > has to have a pointer into that string in all cases. ...
    (comp.lang.c)
  • Re: Change Formula Name
    ... Dim sNew as String, sOld as String ... > I am trying to use a simple "Find & Replace"> and/or "Links Change" plus code that Tom Ogilvy wrote. ...
    (microsoft.public.excel.programming)