Joke Collection Website - Public benefit messages - After the VBA ListBox is assigned a value, the assigned value cannot be displayed normally.

After the VBA ListBox is assigned a value, the assigned value cannot be displayed normally.

The email has been received and is now modified as follows. The display speed is no different than before the modification:

Private Sub CommandButton1_Click()

Dim lngCnt As Long, Wnd As Long

With ListBox1

.Visible = False

Wnd = .TopIndex

For lngCnt = 0 To .ListCount - 1

.ListIndex = lngCnt

.List(lngCnt, 0) = " "

Next

.TopIndex = Wnd

.Visible = True

End With

End Sub

Private Sub CommandButton2_Click()

Dim lngCnt As Long, Wnd As Long

With ListBox1

.Visible = False

Wnd = .TopIndex

For lngCnt = 0 To .ListCount - 1

.ListIndex = lngCnt

.List(lngCnt, 0) = lngCnt

Next

.TopIndex = Wnd

.Visible = True

End With

End Sub

Private Sub CommandButton3_Click()

If ListBox1.ListIndex lt;gt; -1 Then

MsgBox ListBox1.List(ListBox1.ListIndex, 0)

End If

End Sub

Private Sub UserForm_Initialize( )

Dim lngCnt As Long

With ListBox1

.Clear

.ColumnCount = 2

.ColumnWidths = "45; 100"

For lngCnt = 0 To 1000

.AddItem (lngCnt)

.List(lngCnt, 1) = "0000000000" amp ; lngCnt

Next

End With

End Sub

If you still have questions, please send the file to my email:

ljl2008610@63.com