This control is another that I made myself in 1999. I wrote it because I think the ListBox doesn't have as many methods as it could. Most of the functions use the Windows API. None of the functions where items are added to lists are cleared first, so clear the list first if you want to refresh the drive letters for example. Read the text file here and download it here.
List As Object
Puts all drive letters in order into the list specified as one listitem per drive letter. E.g. A:, C: etc.
|
LBAPI1.ListDrives List1 |
List As Object, TextString As String, Index As Integer
Edits an item in the specified list. Replaces the lists' .RemoveItem and .AddItem methods.
|
LBAPI1.ListEdit List1, "Spider-Man", 2 'Changes whatever is in position 2 in List1 to 'Spider-Man' |
List As Object, FolderSpec As String
Puts all full filenames into the list from the folder specified, not including subfolders.
|
LBAPI1.ListFiles List1, "C:\WINDOWS" |

ListFiles
List As Object, SearchSpec As String
Searches the list for the text specified (not case sensitive). ListFindExact only works if the full string is specified, whereas ListFind works with the first part of the string. In this example, the string "The Terminator" is in position 2:
|
MsgBox LBAPI1.ListFind(List1, "The Term") 'Returns
2 MsgBox LBAPI1.ListFindExact(List1, "The Terminator")
'Returns 2 |
List As Object, FolderSpec As String
Puts all full folder paths into the list from the folder specified, not including subfolders.
|
LBAPI1.ListFolders List1, "C:\WINDOWS" |
List As Object
Returns the numbers of selected items of the list.
|
MsgBox LBAPI1.ListGetSelCount(List1) |
List As Object
Returns the length of the text of the selected item in the list.
|
MsgBox LBAPI1.ListGetTextLen(List1) 'Returns -1 if there are no items in the list |
List As Object, Width As Integer
Adds a horizontal scrollbar to a list, which is useful if you have text which is too long to be fully displayed in your list. The Width is in pixels.
|
LBAPI1.ListHoriScroll List1, 1000 |

ListHoriScroll
List As Object, File As String
Loads the contents of a text file into a list.
|
LBAPI1.Listload List1, "C:\WINDOWS\TIPS.TXT" |
List As Object, File As String
Writes the contents of a list to a text file.
|
LBAPI1.ListFiles List1, "C:\" 'Put
something in the list |
| From: | khamlijy rachid |
| Date: | Thursday, June 12, 2003 at 20:44:04 |
| Comments: | MOREV LIST BOX API FONCTION PLEASE |
| From: | vijayasekar J |
| Date: | Saturday, May 29, 2004 at 13:06:43 |
| Comments: | very useful in list box api function.
more anoter api function our mail. |