LB_DELETESTRING Message

Platforms

Description & Usage

Sending the LB_DELETESTRING message to a list box removes one of the items in it.

Return Value

If successful, the message returns the number of items remaining in the list box. If an error occured, the message returns LB_ERR.

Visual Basic-Specific Issues

None.

Parameters

wParam
The zero-based index of the string to delete from the list box.
lParam
Not used -- set to zero.

Constant Definitions

Const LB_DELETESTRING = &H182
Const LB_ERR = -1

Example

When the user clicks button Command1, remove the second item from list box List1. To run this example, place a list box named List1 and a command button named Command1 on a form window.

' This code is licensed according to the terms and conditions listed here.

' Declarations and such needed for the example:
' (Copy them to the (declarations) section of a module.)
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal Msg _
	As Long, wParam As Any, lParam As Any) As Long
Public Const LB_DELETESTRING = &H182
Public Const LB_ERR = -1

' *** Place the following code inside a form window. ***

Private Sub Command1_Click()
	Dim result As Long  ' result of string deletion attempt
	
	' Remove the second item from List1 and display the result.
	result = SendMessage(List1.hWnd, LB_DELETESTRING, ByVal CLng(1), ByVal CLng(0))
	If result = LB_ERR Then
		Debug.Print "Unable to delete the second string in List1."
	Else
		Debug.Print "There are"; result; "strings left in List1."
	End If
End Sub

See Also

LB_ADDSTRING, LB_INSERTSTRING, LB_RESETCONTENT

Category

List Boxes

Back to the Message list.
Back to the Reference section.


Last Modified: December 17, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/l/lb_deletestring.html