Results 1 to 3 of 3

Thread: [RESOLVED] Parse textbox to listbox - help

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    6

    Resolved [RESOLVED] Parse textbox to listbox - help

    How do I parse comma-seperated textbox entries and then populate a listbox?

    In my example I have one textbox, let's say I type in the following:

    comp1,comp2,comp3,comp4

    I'd like to then (upon clicking a command button) have that textbox populate a listbox like so

    comp1
    comp2
    comp3
    comp4

    Thanks for any help.

  2. #2
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: Parse textbox to listbox - help

    Let's assume that you do have "comp1,comp2,comp3,comp4"...the common element here is the "," between each entry.

    So first we do dat = split(txtData,",") which splits the string above (assuming it's in txtData) into dat(0) to dat(3)

    Now we need to add them to the list...that's a simple one too

    VB Code:
    1. for b=0 to ubound(dat())
    2. lstDat.additem dat(b)
    3. next b

    That assumes the list is called lstDat. If that doesn't work, edit the "ubound(dat())" to say "ubound(dat)" (notice i changed dat() to dat...not sure which is right, I'm writing this outside of VB and haven't tested :-))
    Well, everyone else has been doing it :-)
    Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
    Expect more to come in future
    If I have helped you, RATE ME! :-)

    I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!

    And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    6

    Re: Parse textbox to listbox - help

    This worked. Problem solved.

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