Display Multi Selection from the list box

lambuhere1

Registered User.
Local time
Today, 21:49
Joined
Nov 19, 2001
Messages
28
Hi all

I am trying to display the selection made by the user in the list box. Its a Multi Selection List Box. I am trying to display to the user that he/she had selected this, this etc, depending on his/her selection in the list. The following code displays the selection individually. Can you think about displaying all the selection in a single msgbox?

Private Sub CommandButton1_Click()
Dim intloopindex
For intloopindex = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(intloopindex) Then
MsgBox " U have selected " & ListBox1.List(intloopindex)
End If
Next intloopindex

End Sub


I was thinking..... Can we include any loop inside the Message Box? Just a thought.

Thanks for your time.
 
For Each varItem In Me![ListBox1].ItemsSelected
Answer = Answer & Me![ListBox1].Column(0, varItem) & ", "
Next varItem

MsgBox "You selected " & Left(Answer, Len(Answer) - 2)
 
Jack

I tried a way around. But Again a minor error in code.


I am trying to gather and group instrument data. Kindly take a look at the code below.

Sub Grouping_inst()
Dim boxes As Integer, m As Integer, i As Integer, msg As String
boxes = InputBox("How many Instrument groups are there?")
For m = 1 To boxes
MsgBox " Select the group " & m & " instruments "
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
msg = msg & vbCrLf & ListBox1.List(i)
End If
Next i
MsgBox " You have selected " & msg & " for Group " & m
Next m


End Sub

Herein I am asking the user for the input about the total number
of grouped instrumentation. That is assigned in the input box and stored in boxes. Now I want the user to select the grouped instruments in a particular group. Say i have 4 instrument groups. Then I want the user to select the instruments in Group 1 display them as Group 1 selected instruments, and proceed further till I complete the total number of groups of instruments.

FOr Eg.

I have 3 groups. This is the input from the user.

Then the user selects the total instruments in Group 1,say inst 3 inst 5 inst 7,
Display THIS to user for his reference.

Then The user selects the total instruments in Group 2,say inst 8 inst 6 inst1,
Display it to the user

and so on.

If I use the above code of mine, which I know is wrong, the user is not able to select the instruments. I don;t know why?

Can you think a way out ?
Thanks a lot for your help.

Ram P
 

Users who are viewing this thread

Back
Top Bottom