Results 1 to 3 of 3

Thread: [RESOLVED] How to make names of listbox items appear on a message box?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    5

    Resolved [RESOLVED] How to make names of listbox items appear on a message box?

    On the form are 1 listbox and one commandbutton, among others. The command button is for deleting items inside the listbox. If the user clicks the DELETE button, a message box would appear saying "Delete *****, *****, *****?"...I already have the complete code for this procedure, what I need is the code that will make the names of the items appear on the msgbox, example - the message on the message box would read something like this: Delete Apple, Orange, Banana, Lemon? -this is assuming that the user selected Apple, Orange, Banana, and Lemon in the listbox. I need the EXACT code. Thanks a lot!!!

  2. #2
    Hyperactive Member
    Join Date
    Aug 2006
    Location
    TeXaS
    Posts
    497

    Re: How to make names of listbox items appear on a message box?

    i threw this together real quick, it should work. change your objects as needed

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim i As Long
    4.     Dim sCount As Long
    5.     Dim Msg As String
    6.    
    7.     If List1.SelCount = 0 Then
    8.         Exit Sub
    9.     End If
    10.    
    11.     Msg = "Delete"
    12.     For i = 0 To List1.ListCount - 1
    13.         If List1.Selected(i) Then
    14.             sCount = sCount + 1
    15.             Msg = Msg & IIf((sCount = List1.SelCount) And (sCount > 1), " and", vbNullString)
    16.             Msg = Msg & " " & List1.List(i) & ","
    17.         End If
    18.     Next i
    19.     Mid$(Msg, Len(Msg)) = "?"
    20.     MsgBox Msg, vbYesNo, "Delete Items"
    21.    
    22. End Sub

  3. #3
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: How to make names of listbox items appear on a message box?

    Why not just design your own form that displays what you want just like a msgbox. This way you can control everything about it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width