|
-
Apr 21st, 2003, 06:55 PM
#1
Thread Starter
Addicted Member
For or Do statement for Listboxes [Resolved]
I have a listbox (currently project is in VB.NET but could do in VB6. The listbox contains a list of items. What would the syntax be for a For or Do statement that would perform an action for each item that is checked\highlighted?
IE. 6 names in a listbox, 3 are highlighted. What would the statement look like if I wanted a msgbox to pop-up for each of their names?
I cannot figure out the syntax.
Thanks,
Jim
Last edited by jlegan; Apr 21st, 2003 at 08:34 PM.
-
Apr 21st, 2003, 07:17 PM
#2
VB Code:
Dim n As Long, nCount As Long
nCount = List1.ListCount - 1
For n = 0 To nCount
If List1.Selected(n) Then
MsgBox List1.List(n)
End If
Next
That code is for VB6, I don't have VB.Net installed on the computer I'm currently on and don't really know if you would do it in a smarter way with that.
-
Apr 21st, 2003, 07:22 PM
#3
Fanatic Member
VB Code:
Dim i As Integer, j As Integer
Do Until i = List1.SelCount
If List1.Selected(j) = True Then
List2.AddItem List1.List(j)
i = i + 1
End If
j = j + 1
Loop
edit: almost same post time, it took me a sec to whip up the code. His is shorter go with that.
Last edited by Mushroom Realm; Apr 21st, 2003 at 07:51 PM.
-
Apr 21st, 2003, 07:29 PM
#4
Thread Starter
Addicted Member
Mushroom,
Where did the second list come in?
-
Apr 21st, 2003, 07:52 PM
#5
Fanatic Member
Oh, I forgot it said to have a messagebox pop up.
-
Apr 21st, 2003, 07:58 PM
#6
Thread Starter
Addicted Member
Do you know the syntax for .NET?
-
Apr 21st, 2003, 11:13 PM
#7
Fanatic Member
Post a link to this thread in the .NET forum. They would know, but it might take a little longer.
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
|