It should look something like this as far as I can tell. This is not my code, I found this information here:
http://www.thescripts.com/forum/thread399839.html
-
Dim objX as Object
-
For Each objX in lstBox.SelectedItems
-
'Do Something
-
Next
-
If you are using VB 6 or below the problem is there isnt a .SelectedItems Method, that is .NET and the link is for .NET, something like this could be of help to you
Going on the basis that your other form is called "MyFormName" which you can change lol, The text box you are transfering the information to is called "Text1" and the List
- Private Sub Command1_Click()
-
Dim i As Integer
-
-
MyFormName.Text1.Text = "" 'Clear The Text Box For Use
-
MyFormName.Text1.MultiLine = True 'Make Sure The Text Box Is Multiline
-
-
'Loop through the items in the List Box (Named: List1)
-
For i = 0 To List1.ListCount - 1
-
-
If List1.Selected(i) = True Then 'If The List Item Is Selected
-
-
With MyFormName 'With The Other Form
-
-
.Text1.Text = .Text1.Text & List1.List(i) 'Add The Selected Text
-
.Text1.Text = .Text1.Text & vbCrLf 'Next Line After The Added Text
-
-
End With 'End With The Other Form
-
End If
-
Next
-
MyFormName.Show 'Show the other form.
-
End Sub
Comments are included so that you can determine what each line of code does, (Turns green when in the code explorer screen), but i hope this helps you
Brief Rundown:
For i = 0 to List1.listcount - 1 : The listbox's list starts at 0, where as the count does not, so to stop it getting confused - 1 from the list count
vbCrLf: Next line
With MyFormName: means you dont have to type out MyFormName.Text1.Text everytime you want to do something with an object on that particular form.
Hope This Helps
Kind Regards
Devon.