• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

Transfer multi selection from list box to text box

Hello all

I have a list box (check style) in form45.

What i want to do it to be able to select, 1 or more selection from the list and when i click on the button, it will transfer all items selected from the list in my Form44.carrier_names (Textbox).

For ex: if i have only once selected in my list box, called "26". Then it will put "26" in my Form44.carrier_names (Textbox).

But is i have for example 3 selection, "08" "21" and "28". then it will transfert to the text box like this:

How can i do this please.

Thanks again for your help.

Form44.carrier_names = form45. List1

Open in new window

  • 3
1 Solution
Martin LissOlder than dirtCommented:
Set the Multiline property of the textbox to True. Then loop through the Listitems looking for those selected and then add them with vbCrLf at the end of each one.
Martin LissOlder than dirtCommented:
Like so

Dim lngIndex As Long

For lngIndex = 0 To List1.ListCount - 1
    If List1.Selected(lngIndex) Then
        Text1.Text = Text1.Text & List1.List(lngIndex) & vbCrLf
    End If

Open in new window

Wilder1626Author Commented:
Thanks, this is perfect
Martin LissOlder than dirtCommented:
Thanks. If you want to get rid of the last vbCrLf do

Text1.Text = Left$(Text1.Text, Len(Text1.Text) - 2)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now