Private Sub Form_Load()
Dim ItemHeight As Long
Dim Items As Integer
ItemHeight = SendMessage(List1.hwnd, LB_GETITEMHEIGHT, 0, 0&)
Items = (List1.Height - 2 * Screen.TwipsPerPixelY) _
/ (Screen.TwipsPerPixelY * ItemHeight)
Text1.Text = "Maximalt # poster : " & Str(Items)
List1.AddItem "Item #1"
List1.AddItem "Item #2"
List1.AddItem "Item #3"
End Sub
Private Sub Command1_Click()
Dim ItemHeight As Long
Dim Items As Integer
Dim X As Integer
ItemHeight = SendMessage(List1.hwnd, LB_GETITEMHEIGHT, 0, 0&)
Items = (List1.Height - 2 * Screen.TwipsPerPixelY) _
/ (Screen.TwipsPerPixelY * ItemHeight)
X = List1.ListCount
X = X + 1
If X <= Items Then
List1.AddItem "Post nr #" & Str(X)
End If
End Sub