|
-
May 27th, 2003, 08:44 AM
#1
Thread Starter
Lively Member
MultiSelect Listbox(*Resolved*)
I need to get the actual text of a multiselect textbox and put them all into a string. The items are "ListItem1", "ListItem2" ...
"ListItem50"
So that at the end I can basically say "you Chose ListItem1, ListItem5, ListItem28, ListItem40 ...
I can get only the last item text and not all of them.
Any help?
Thanks,
Michael
Last edited by IGBP; May 27th, 2003 at 09:54 AM.
-
May 27th, 2003, 08:50 AM
#2
You need to loop through them and say
VB Code:
If List1.Selected(x) Then
'Item x is selected
End If
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
May 27th, 2003, 09:06 AM
#3
Thread Starter
Lively Member
crptcblade
Can you provide a short example, please :-) I am not having any luck in how I have tried to construct the loop.
-
May 27th, 2003, 09:49 AM
#4
Let me in ..
Originally posted by IGBP
crptcblade
Can you provide a short example, please :-) I am not having any luck in how I have tried to construct the loop.
Put a listbox and command button on a form and use this .... this should give you enough idea ....
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim l_strMonths As String
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
If Trim(l_strMonths) = "" Then
l_strMonths = MonthName(i + 1)
Else
l_strMonths = l_strMonths & ", " & MonthName(i + 1)
End If
End If
Next
MsgBox "You chose ... " & l_strMonths
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 12
List1.AddItem MonthName(i)
Next
Command1.Caption = "Show selected"
End Sub
-
May 27th, 2003, 09:55 AM
#5
Thread Starter
Lively Member
Thanks guys...
I think I can get it from there :-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|