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

0
Avatar
Legacy Poster

I'm creating  a lable that extracts data from the DB in a memo field that has multilpe lines of data.

I just need to read and display the first 2 line from that field.

 

Thanks.

3 comments

0
Avatar
Ian Cummings
Moderator
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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.

Please sign in to leave a comment.