Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another list question

Status
Not open for further replies.

r3b00t

Technical User
Aug 13, 2002
45
GB
Sorry about this guys but ive yet another question if yous wouldnt mind helping me out.

When ive got an item selected in the listbox and click the delete command button, a msgbox appears giving the options of yes to delete or no to cancel the operation.

The code ive got goes like this:

Private Sub cmdDelete_Click()
MsgBox "Are you sure you want to delete this callback?", vbYesNo, "Confirm Delete"
On Error Resume Next
' If Yes is clicked then delete selected item
If vbYes Then
List1.RemoveItem (List1.ListIndex)
End If
End Sub

I know ive got to enter ElseIf vbNo then but dont know what to enter after this =$

Anybody help?!?

Cheers

r3b00t
 
You need to use the messagebox function instead of the command.

Private Sub cmdDelete_Click()
Dim Result as String
Result = MsgBox ("Are you sure you want to delete this callback?", vbYesNo, "Confirm Delete")
On Error Resume Next
' If Yes is clicked then delete selected item
If Result = vbYes Then
List1.RemoveItem (List1.ListIndex)
End If
End Sub

A vbNo result will simply exit the sub, so you do not need to have a ElseIf line.

Robert
 
Cheers m8, all cleared up!

Thanx again

r3b00t
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top