Results 1 to 4 of 4

Thread: String value

  1. #1
    Join Date
    Dec 2007
    Posts
    6

    Unanswered: String value

    Hello,

    I'm trying to replace a string value with the following condition.

    As soon as the string hits a period (.) I'm trying to surpress the remaining string value including the firlst period.

    "LaplanteC.IOD.CDB.1234.HQ.TEST.CA"
    should now read "LaplanteC"

    Any ideas?

    Thx

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    stringVar str
    
    str = "LaplanteC.IOD.CDB.1234.HQ.TEST.CA" 
    
    Left(str, InStr(1, str, ".") - 1)
    George
    Home | Blog

  3. #3
    Join Date
    Dec 2007
    Posts
    6
    the formula doesn't seem to work in Crystal Reports, I get the error message indicating "String length is less than 0 or not an integer".

    stringVar str

    str = "LaplanteC.IOD.CDB.1234.HQ.TEST.CA"

    Left(str, InStr(1, str, ".") - 1)

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Ugh, forgot the crystal syntax for this function.
    Code:
    stringVar str;
    
    str := "LaplanteC.IOD.CDB.1234.HQ.TEST.CA";
    
    Left(str, InStr(str, ".") -1)
    As you've already found; if there is no period then the formula will throw an error
    I.e. left(str, -1) which cannot be done. You'll have to write an if statement to check and process accordingly
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •