×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Writing a macro... replace function?

Writing a macro... replace function?

Writing a macro... replace function?

(OP)
I have been searching high and low for a replace function! Basically I just need to write something that looks at a string, removes all the double quotes and returns a clean string. We're doing process automation and our files come down in CSV format with quotes included.

I must not be looking hard enough because this is an elementary function. Anyone have an equivalent they've written? I'm about to toss this computer out the window, scaring the squirrels.

RE: Writing a macro... replace function?




Hi,

You're going to have to write your own function.  Loop thru the characters in the string, looking to the replace value.

Skip,
glassesDon't let the Diatribe...
talk you to death!tongue

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Writing a macro... replace function?

Does Extra! Basic have a Replace function similar to MS VB?

myStr = Replace(MyStr, """", "")

 

RE: Writing a macro... replace function?




Have you checked in Extra Basic HELP?

Skip,
glassesDon't let the Diatribe...
talk you to death!tongue

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Writing a macro... replace function?

(OP)
I checked and saw nothing in there.

I doctored up two solutions... one replaces a string with nothing, and one replaces a string with something:

Function RemoveChars(strText As String, strUnwanted As String) As String

    Dim TempStr, CurChar As String
    Dim x As Integer
    
    For x = 1 To Len(strText)
        CurChar = Mid(strText, x, 1)
        If InStr(strUnwanted, CurChar) = 0 Then TempStr = TempStr & CurChar
    Next x
    RemoveChars = TempStr
    
End Function

Function ReplaceChars(strText As String, strUnwanted As String, strWanted as String) As String

    Dim currLoc As Integer
    Dim StringLength As Integer
    Dim tmpChar As String

    StringLength = Len(strText)
    For currLoc = 1 To StringLength
        tmpChar = Mid(strText, currLoc, 1)
        If InStr(strUnwanted, tmpChar) Then
            ' Replace with the new character
            Mid(strText, currLoc, 1) = strWanted
        End If
    Next

    RemoveCharacters = strText

End Function

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close