|
-
Jul 8th, 2003, 04:37 PM
#1
Thread Starter
Member
RESOLVED - Return a String of Selected Items in Listbox
I have a listbox that is populated with years.
2001 <-Selected
2002 <-Selected
2003
2004 <-Selected
2005
I want to return a string based upon the selections made.
Example: 2001,2002,2004
Code:
Dim z As Integer
Dim Ystr as String
For z = 0 To (lstForecastYears.ListCount - 1)
If lstForecastYears.Selected(z) = True Then
Ystr = lstForecastYears.List(z)
End If
Msgbox Ystr
Next
I'm returning the correct selections but how do I get into a string format with the delimiters?
Thanks.
Last edited by Suidae; Jul 8th, 2003 at 05:14 PM.
I'm a misanthropic philanthropist!
Frog, the only white meat...
-
Jul 8th, 2003, 04:57 PM
#2
Try this :
VB Code:
Dim z As Integer
Dim Ystr as String
Ystr = ""
For z = 0 To (lstForecastYears.ListCount - 1)
If lstForecastYears.Selected(z) = True Then
Ystr = Ystr & lstForecastYears.List(z) & ","
End If
Next
Ystr = Left$(Ystr, Len(Ystr) - 1) 'This is just to remove the last comma
Msgbox Ystr
Last edited by manavo11; Jul 8th, 2003 at 05:01 PM.
Has someone helped you? Then you can Rate their helpful post. 
-
Jul 8th, 2003, 05:14 PM
#3
Thread Starter
Member
I'm a misanthropic philanthropist!
Frog, the only white meat...
-
Jul 8th, 2003, 05:22 PM
#4
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
|