Using VBScript Replace Function in ActiveXScript Task

  • I'm writing an ActiveXScript task to remove extra commas from a text file prior to loading into my database.  I am trying to use the VBScript text function, as shown here:

    Function Main()

     Dim strPhrase1

     Set strPhrase1 = "S&S SIMSBURY,CT"

     replace(strPhase1,","," ")

     Main = DTSTaskExecResult_Success

    End Function

    When I parse the code, I receive the following error message:

    Cannot use parentheses when calling a sub

    How should I call this function within the ActiveXScript task?

    “If you're not outraged at the media, you haven't been paying attention.”

  • First, don't use "Set" to assign a value to a variable.  "Set" is used to initialize an Object, which a variable is not.

    Secondly, you have to assign the output of the function to something, otherwise VBScript thinks you are calling a subroutine.

     

    Function Main()

     Dim strPhrase1

     strPhrase1 = "S&S SIMSBURY,CT"

     strPhrase1 = replace(strPhase1,","," ")

     Main = DTSTaskExecResult_Success

    End Function

     

  • Okay, that was easy enough.  Thanks!

    “If you're not outraged at the media, you haven't been paying attention.”

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply