Tác giả : paulsteigel
Nguồn: http://thuthuataccess.com
Hàm sau sẽ giúp bạn liệt kê các form trong Chương trình và đưa vào 1 listbox.
Nguồn: http://thuthuataccess.com
Hàm sau sẽ giúp bạn liệt kê các form trong Chương trình và đưa vào 1 listbox.
Function SortListBox(objListBox As ListBox)Bạn tạo 1 module mới rồi copy đoạn code trên vào.
Dim intFirst As Integer
Dim intLast As Integer
Dim intNumItems As Integer
Dim i As Integer
Dim j As Integer
Dim strTemp As String
Dim MyArray() As Variant
'Re-Dim the array
ReDim MyArray(objListBox.ListCount - 1)
'Get upper and lower boundary
intFirst = LBound(MyArray)
intLast = UBound(MyArray)
'Set array values
For i = LBound(MyArray) To UBound(MyArray)
MyArray(i) = objListBox.ItemData(i)
Next i
'Loop through array values to determine sort
For i = intFirst To intLast - 1
For j = i + 1 To intLast
If MyArray(i) > MyArray(j) Then
strTemp = MyArray(j)
MyArray(j) = MyArray(i)
MyArray(i) = strTemp
End If
Next j
Next i
'Remove all items
For i = intLast - 1 To intFirst Step -1
objListBox.RemoveItem i
Next i
'Add all items in order
For i = intFirst To intLast - 1
objListBox.AddItem MyArray(i), i
Next
End Function
Private Sub Command1_Click()
Call SortListBox(List0)
End Sub