locked
extract string in between RRS feed

  • Question

  • User564383478 posted

    Dears, I developed crystal report using the tool available with VS2005. I need  help for extracting a string in a formula field.

    Example :

    String= CFG:69|  result should be 69

    String= CFG:1269|  result should be 1269

    in the string always starting part is "CFG" and ending part is "|"


    how can i trim the string in between.

    i wrote the function like  Mid ({ReportsVT_jul;1.messages},5 )  but the ending part is not removing...how can i do this pls help me.



    Sunday, August 1, 2010 10:26 AM

Answers

  • User1224194097 posted

    string strResult  = strInput.Substring(3, strInput.Length - 3); 

    That won't work, Crystal reports do not have any function SUBSTRING as such, you have to MID or left/Right to trim the characters that you want

    use this

    Replace(mid("CFG:1269|",5),"|","")


    That should replace the the pipe symbol after extracting from the fifth character.

    if you do not want to use replace,you can use number of characters to extract, but in your case it varies.

    try that and see if it works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 1, 2010 11:23 AM

All replies

  • User-1734649046 posted

    Hi,

    Please refer following

    //input string
    string strInput = "CFG:69|";
    
    string strResult  = strInput.Substring(3, strInput.Length - 3);
    strResult = strResult.Substring(0, strResult.Length - 1);


    Also please refer following

    http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/3b0e6895-a55f-4617-b29b-b0016127c2eb

    hope this helps

    Sunday, August 1, 2010 11:09 AM
  • User1224194097 posted

    string strResult  = strInput.Substring(3, strInput.Length - 3); 

    That won't work, Crystal reports do not have any function SUBSTRING as such, you have to MID or left/Right to trim the characters that you want

    use this

    Replace(mid("CFG:1269|",5),"|","")


    That should replace the the pipe symbol after extracting from the fifth character.

    if you do not want to use replace,you can use number of characters to extract, but in your case it varies.

    try that and see if it works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 1, 2010 11:23 AM