Microsoft KB Archive/103682

{| = PRB: "&" in Controls Does Not Work as Expected =
 * width="100%"|

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
 * }