none
Replace function RRS feed

  • Question

  • Hi,

    Can anyone tell the use of "Replace" function as one I have below- I need to understand what the below exp. doing exactly?

    =Replace(
                  Replace(
                             Replace(
                                         Replace(Fields!filter.Value, "Report Currency=USD,", "")
                             , "Report Currency=USD", "")
                   , "Report Currency=", "")
       , ",", "," & vbCrLf)




    Any link to Replace function will help.

    Thanks, 
    Monday, March 8, 2010 9:16 PM

Answers

  • The replace function takes three inputs:
    1)  The object to be searched (in your example, Fields!filter.Value)
    2)  The string that is being looked for within the object in 1 (in your example, "Report Currency=USD,")
    3)  The string that will replace 2 (in your example, an empty string)


    So if Fields!filter.Value currently returns "Report Currency=USD,$100.25", the function Replace(Fields!filter.Value, "Report Currency=USD,", "") will cause it to instead return "$100.25".

    The final Replace function will search for a comma, and will replace it with a comma & vbCrLf.

    I hope this helps.

    Aaron Jarboe

    -Remember to mark as an answer if this post has helped you.
    Monday, March 8, 2010 9:21 PM

All replies

  • The replace function takes three inputs:
    1)  The object to be searched (in your example, Fields!filter.Value)
    2)  The string that is being looked for within the object in 1 (in your example, "Report Currency=USD,")
    3)  The string that will replace 2 (in your example, an empty string)


    So if Fields!filter.Value currently returns "Report Currency=USD,$100.25", the function Replace(Fields!filter.Value, "Report Currency=USD,", "") will cause it to instead return "$100.25".

    The final Replace function will search for a comma, and will replace it with a comma & vbCrLf.

    I hope this helps.

    Aaron Jarboe

    -Remember to mark as an answer if this post has helped you.
    Monday, March 8, 2010 9:21 PM
  • Hi Tej,

    Also, a reference to the function:

    http://msdn.microsoft.com/en-us/library/bt3szac5(VS.80).aspx

    Boyan Penev --- http://www.bp-msbi.com
    Tuesday, March 9, 2010 2:42 AM
  • Hi Tej-BI,

    Replace Function: Returns a string in which a specified substring has been replaced with another substring a specified number of times. You can get the detail information about its Syntax and examples from this link   http://msdn.microsoft.com/en-us/library/bt3szac5(VS.80).aspx

    So the function that your expression achieved is to delete the string "Report Currency=USD,"in your string "Fields!filter.Value" ,then delete the string "Report Currency=USD"and "Report Currency=" ,lastly , change your string  to a new line when meet comma .

    If you still have question after trying this, please provide your data sample.
    Thanks

    Challen Foo

    Wednesday, March 10, 2010 9:42 AM
    Moderator
  • Hi,

    Thanks all for the reply. I got it.
    One thing, Aaron can you tell me about the final Replace- i did not understand it syntactically and what is vbCrLf.

    Thanks again all..
    Wednesday, March 10, 2010 8:29 PM
  • vbcrlf is to give one line break (carriage return and line feed)

    Wednesday, March 10, 2010 8:35 PM