There seems to be some problem with Run-time control of the Height of a List Box.

lboxText.Height = X does not work for all values of X

At least that what seems to happen. When I had a problem with an application, I made up the following Test Code.
VB Code:
  1. Private Sub cmdHeight_Click()
  2. Dim J As Integer
  3. Dim Tally As Integer
  4.  
  5. lboxTest.Font = "MS Sans Serif"
  6. lboxTest.FontBold = True
  7. lboxTest.FontSize = 10
  8. lboxTest.Clear
  9. lboxA.Clear
  10. lboxB.Clear
  11.  
  12. Tally = -200
  13.  
  14. For J = 100 To 2000
  15.         lboxTest.Height = J
  16.         If lboxTest.Height = J Then
  17.                 lboxA.AddItem CStr(J) & " / " & CStr(lboxTest.Height)
  18.             Else
  19.                 lboxB.AddItem CStr(J) & " / " & CStr(lboxTest.Height)
  20.           End If
  21.        
  22.         'Tally = Tally + 1
  23.         'If Tally > 0 Then
  24.                 'Exit Sub
  25.             'End If
  26.     Next J
  27.        
  28. End Sub
The above uses a Form with a Command Button (cmdHeight), and three List Boxes: lboxTest, lboxA, & lboxB. It attempts to set the Height of the Test List Box. The results of the attempts are recorded in two other List Boxes: One showing successful attempts and one showing situations for which the height was not set as specified.

I was astonished when I ran the above and examined the contents of List Boxes A & B.

Did I do something wrong? Am I misunderstanding something simple? Has anybody else encountered a similar situation?

The results vary depending on the Font parameters for lboxTest.

For my application, I wanted to change the height of a List Box depending on how many items were to be put into it. To identify each item in the List Box, I wanted to put Labels on the form to the left of the List Box.

To do the above required precise run-time control of the height of the list Box. which does not seem to be possible.