List Boxes Can Shrink When a Form Is Saved in Text Format

ID: Q141940

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic,

  16-bit only, for Windows, version 3.0

SYMPTOMS

Every time a project is run, a list box appears with a smaller height than when the form was previously saved. The behavior seems to depend on whether the form was saved in text format or binary, and the font used in the list box. The list box does not grow any smaller once an executable is made.

The same problem described above can also occur for a file list box.

STATUS

This problem was fixed in both 16- and 32-bit versions of Visual Basic 4.0 (where all forms are saved only in a text format).

MORE INFORMATION

The problem described above occurs under certain circumstances. First, the height of the list box shrinks after the form has been saved in text format. (To save a form in text format, highlight the form in the project window and on the File menu, click Save File As, with the Save As Text check box selected.) If the form is saved consistently in the Binary format, then the problem is not reproducible.

Secondly, the problem seems to only occur for certain fonts in the list box. MS Sans Serif and Truetype fonts such as Arial are font choices where the problem does not occur. Small Fonts and Courier are examples of fonts in the list box where the problem does occur.

RESOLUTION

The following are three possible workarounds:

Steps to Reproduce the Problem

1. Start a new Visual Basic project. Form1 appears by default.

2. Place a list box on the form (it will be called List1 by default) and

   set the height property of the list box to 6630 twips (or a suitable
   high value).

3. In the property window, set the FontName for the list box to Small
   Fonts. Also, type in a size of 24 for the font (the problem occurs for
   all sizes of the font, but is most easily seen for larger sizes).

4. In the Activate event for the form, place the following line of code:

      Debug.Print List1.Height

5. Run the program by pressing the F5 key. Notice that the Debug window
   correctly shows the original height of the list box. Stop the program.

6. Save Form1 in a text format, that is, on the File menu, click Save File
   As, and check the Save As Text check box.

7. Run the program by pressing the F5 key. Notice that the debug window
   still shows the original height of the list box. Stop the program.

8. Save Form1 once again in text format--when Visual Basic asks if you
   want to replace Form1, click Yes.

9. Run the program again. Now the Debug window shows that the list box
   height has decreased to 6030 twips.

After each successive save of the form in text format, the list box height will decrease every time the project is run. However, the problem only surfaces after the second save of the form in text format.

Additional query words: kbVBp300bug kbVBp400bug kbVBp kbdsd kbDSupport kbControl

Version           : 3.00
Platform          : WINDOWS
Issue type        : kbbug

Last Reviewed: August 7, 1998