Results 1 to 6 of 6

Thread: [RESOLVED] How to take text from listbox and put in textbox?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    177

    Resolved [RESOLVED] How to take text from listbox and put in textbox?

    How do i take the text from a listbox and put it in a textbox?

  2. #2
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: How to take text from listbox and put in textbox?

    well, if you use the Select Case function, you could say

    Code:
    Select Case lstWhatever
    Case0 "Hi"
    txtWhatever.text="Hi"
    Case1 "Hello"
    txtWhatever.text="Hello"
    End Select
    Like that.
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How to take text from listbox and put in textbox?

    What do you want to take from the listbox? All of the listitems or specific listitems?
    List1.List(0) is the 1st item, List1.List(1) is 2nd item & so on.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    177

    Re: How to take text from listbox and put in textbox?

    Id like to take all the items LaVolpe if you could help please thanks.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    177

    Re: How to take text from listbox and put in textbox?

    I have tried

    Code:
    Private Sub Command1_Click()
    Dim i As Integer
    For i = 0 To List1.ListCount
    i = i + 1
    Text1.Text = List1.List(i)
    Next i
    End Sub
    But text1 just stays blank.

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How to take text from listbox and put in textbox?

    Almost. A couple of things
    1. The loop variable, i, is automatically incremented in a For:Next loop. Do not increment it yourself.
    2. Your textbox must have MultiLine=True to display more than one line. Also when you append text and want a new line, you should use vbNewLine
    3. List items are zero-bound, this means you cannot loop to List1.ListCount, must be List1.ListCount-1

    Tweaking your loop code only
    Code:
    For i = 0 To List1.ListCount - 1
        Text1.Text = Text1.Text & List1.List(i) & vbNewLine
    Next i
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width