martin2k

ForumsVB6GamesSoftwareDirectoryHTMLArticlesBlogContact

List Box API Functions


 

Home

Read and add posts to the Visual Basic 6.0 Forums

Download some of my programs and OCXs

Read the Tips here

The old style forum is still available here

Contact


 

ActiveX Control

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.

Methods

ListDrives

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

ListEdit

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'

ListFiles

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
ListFiles

ListFind & ListFindExact

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.ListFind(List1, "Terminator") 'Returns -1

MsgBox LBAPI1.ListFindExact(List1, "The Terminator") 'Returns 2
MsgBox LBAPI1.ListFindExact(List1, "The Term") 'Returns -1

ListFolders

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"

ListGetSelCount

List As Object

Returns the numbers of selected items of the list.

MsgBox LBAPI1.ListGetSelCount(List1)

ListGetTextLen

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

ListHoriScroll

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
ListHoriScroll

Listload

List As Object, File As String

Loads the contents of a text file into a list.

LBAPI1.Listload List1, "C:\WINDOWS\TIPS.TXT"

Listsave

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
LBAPI1.Listsave List1, "C:\WINDOWS\DESKTOP\List1.txt"


blog comments powered by Disqus

Archived Comments

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.


Martin Allen 1999 - 2011.  Last updated Wednesday 10 August 2011 07:38:21 PM +0100.