Skip to main content

Search

Search

Vb Script To Read Only The First 2 Line Of A Memo Field.

Comments

3 comments

  • Avatar
    Ian Cummings
    Moderator

    Have you tried using the "Truncation" transform to discard the characters of data that you don't want?  Are the "lines of data" marked by a fixed character length, or a carriage return and line feed?

    0
  • Avatar
    Legacy Poster

    I have used trancation, and it does not work for all the data.

    The data in the memo field may have several lines and I wanted to only pull out the first 2 lines.

    They are not of a fixed lenght. They do have carriage return after each line.

    0
  • Avatar
    Ian Cummings
    Moderator

    Then use a VB script to find the position in the string of the second carriage return Chr(13) using the InStr() function, and then use the Left() function to set the value of the data source as being only everything to the left of that position value.

     

    InStr Function
    Returns the position of the first occurrence of one string within another.
     
    InStr([start, ]string1, string2[, compare])
     
    Arguments
     
    start
    Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start contains Null, an error occurs. The start argument is required if compare is specified.
     
    string1
    Required. String expression being searched.
     
    string2
    Required. String expression searched for.
     
    compare
    Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. If omitted, a binary comparison is performed.
    0

Please sign in to leave a comment.