Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jun 2002
    Location
    Toronto, Ontario
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Add to combobox from external File (VB6)

    Is it possible to populate a combo box at run time with data from an external file?
    I am using a drop down combo box for selection of the client.
    I have a list of clients that will change and I want to be able to make the changes without re-compiling the executable every time a client is added.
    If not, what other solution can I use?
    Help please.

    John

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add to combobox from external File (VB6)

    Yes it is, but how are you populating the combobo now?
    Charlotte

  3. #3
    Lounger
    Join Date
    Jun 2002
    Location
    Toronto, Ontario
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Add to combobox from external File (VB6)

    Charlotte,

    I have pasted a list into the properties of the combobox - list.

    My first item in the list is "!ADD CLIENT" if this item is selected I then open an input box and ask for the new client name.
    Then I change cboClient to strNewClient by cboClient = strNewClient. But of course, when the program ends this new client is not added.

    John

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add to combobox from external File (VB6)

    You need to either base your list of clients on a query or table or else use AddItem to populate a simple list and then to add the new name to it. If you want to control the contents of the list like this, then I'd say that AddItem is the method you need to use.
    Charlotte

  5. #5
    Lounger
    Join Date
    Jun 2002
    Location
    Toronto, Ontario
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Add to combobox from external File (VB6)

    Charlotte,

    This is what I ended up doing,
    ----snip------
    strClientListFileName = "ClientList.txt"

    Open App.Path & "" & strClientListFileName For Input As #3
    '----------------------------------------------------------------------------'

    Do Until EOF(3)
    Line Input #3, NextLine
    cboClient.AddItem NextLine
    Loop
    Close #3
    ----snip------
    Then I do some other stuff then before I close ...
    ----snip------
    '----------------------------------------------------------------------------'
    ' Write New Client to ClientList.txt
    '----------------------------------------------------------------------------'
    Open App.Path & "" & strClientListFileName For Append As #3

    Print #3, strAddedClient
    Print #3,

    Close #3
    ----snip------

    Seems to work.

    John

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add to combobox from external File (VB6)

    Glad you found a solution that works. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>
    Charlotte

Posting Permissions

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