Microsoft KB Archive/111672

= How to Use a Portion of a Memo Field in a List Box =

Article ID: 111672

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.0
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5b for Macintosh

-



This article was previously published under Q111672



SUMMARY
This article describes how to effectively use a portion of a memo field in a list box object that is part of a user-defined screen.



MORE INFORMATION
To illustrate how to use a portion of a memo field in a list box object, suppose that the first 40 characters of the memo field are needed for the list box.

If a list box object is created using the Screen Builder and the List Items From Field option is selected, then a reasonable expression to enter in the field expression dialog window is:

LEFT( ,40)

This expression will work well as long as all the first lines of all the memo fields in each record are at least 40 characters. If this is not the case, for example, if some of the memo fields have first lines that are less than 40 characters, the above statement will return the carriage return (CR) and linefeed (LF) characters and display them in the list box. Since this is not a desirable side-effect, the following two expressions will correct this situation.

NOTE: Although the first expression works well, the second expression provides a more concise solution.

LEFT( ,IIF(AT(CHR(13), );

<40,AT(CHR(13), )-1,40))

-or-

LEFT(MLINE( ,1),40)

The second expression works because the MLINE function is going to return the characters for the first line of the memo field, up to but not including the CR/LF characters.

The only thing to watch out for concerning the second expression is the current SET MEMOWIDTH value (the default line length is 50 characters). If the MEMOWIDTH is less than 40, no error will result, but only the number of characters corresponding to the MEMOWIDTH value will be returned. For example, if the MEMOWIDTH value is 35, only 35 characters will be returned from the second expression.

Additional query words: VFoxWin FoxMac FoxDos FoxWin listbox

Keywords: kbcode KB111672

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.