PRB: "&" in Controls Does Not Work as Expected

Last reviewed: June 27, 1995
Article ID: Q103682
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SYMPTOMS

The ampersand (&) character will not display in some controls and instead will show the next character as being underlined. For example, the following procedure works differently in FoxPro for Windows and FoxPro for MS-DOS:

  1. In a new screen, add a popup object. In the Popup Prompts box, type the following three prompts:

          This & That
          Tom & Jerry
          Curly & Moe
    

  2. As soon as you assign a variable name and choose OK, you will see the popup prompt displayed as

          This _That
    

If you select "This _That" so that it drops down, you will then see "This & That" as well as the other correctly displayed prompts. However, as soon as you select a prompt, its display will return to being an underscore and no space instead of the &.

The same result occurs in FoxPro versions 2.5 and 2.5a for Windows. This behavior does not affect any version of FoxPro for MS-DOS.

CAUSE

This behavior occurs because of a limitation of the Windows environment. Similar behavior will be exhibited in other Windows-based applications such as Visual Basic. This behavior is by design, and changing this behavior would make FoxPro for Windows behave in a manner inconsistent with other Windows-based applications.

RESOLUTION

To display an ampersand character in Windows, use a double ampersand (&&). In some cases, you can use the following procedure:

  1. In the Screen Setup Code snippet, type:

          m.myvar = "This &"+"& That"
    

  2. In the Popup Prompts box for the list box control, type "&myvar" (without the quotation marks) instead of "This & That".

    NOTE: You cannot directly type

          m.myvar = "This && That"
    

    because FoxPro will assume that everything after the double ampersand is a comment and return an error.


Additional reference words: FoxWin 2.50 2.50a listbox
KBCategory: kbprg kbprb
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.