list box item

Discussion in 'AutoCAD' started by elise_moss, Mar 16, 2005.

  1. elise_moss

    elise_moss Guest

    I am working in VB6.


    I want to get the itemno for the list text selected from a list box. I want to be able to correspond some data from two text files...one txt file populates the list box and the second txt file lists a corresponding file that would be opened based on the line selected in the list box.

    I know it is something like Set itemno = List.ListItem(?)

    Thanks,

    Elise Moss
    www.mossdesigns.com
     
    elise_moss, Mar 16, 2005
    #1
  2. elise_moss

    TomD Guest

    From the help files:
     
    TomD, Mar 16, 2005
    #2
  3. elise_moss

    Anne Brown Guest

    Tom -

    Nothing attached?
     
    Anne Brown, Mar 16, 2005
    #3
  4. something like this. Same idea in the click event
    to open the file necessary.

    Private Sub UserForm_Initialize()
    Dim txtFile As Integer: txtFile = FreeFile
    Dim nextLine As String

    Open "c:\listBoxData.txt" For Input As txtFile

    Do Until EOF(txtFile)
    Line Input #txtFile, nextLine
    ListBox1.AddItem nextLine
    Loop
    End Sub
     
    Paul Richardson, Mar 16, 2005
    #4
  5. Might it be easier to read both files at the same time? You could use
    the index number from the list as an index into a collection or dictionary.
     
    Frank Oquendo, Mar 16, 2005
    #5
  6.  
    Paul Richardson, Mar 16, 2005
    #6
  7. make sure you close the file alos...

    Close txtFile
     
    Paul Richardson, Mar 16, 2005
    #7
  8. elise_moss

    TomD Guest

    Inadvertant key combination mistake.

    No help, just snide comment?
     
    TomD, Mar 16, 2005
    #8
  9. elise_moss

    elise_moss Guest

    None of you answered my question. I know how to populate the listbox using the text file using the methods in your responses.

    I want to know once the user has made the selection...I can get the text value, but I can not get the item value (whether it was line 1 or line 50).
     
    elise_moss, Mar 18, 2005
    #9
  10. ListBox.ListIndex

    and if it's not what you wanted maybe a clearer descripton will help

    - alfred -
     
    Alfred NESWADBA, Mar 18, 2005
    #10
  11. Not a very gracious way to ask for help, Ms. Moss.
     
    Frank Oquendo, Mar 18, 2005
    #11
  12. elise_moss

    elise_moss Guest

    My question was extremely specific, Frank, and written in such a way so that people could provide a quick response. It was obvious from the majority of the respondents that they did not read the question. The majority of respondents assumed the question was how to populate a list box from a text file and that was NOT the question.

    Maybe I *was* SNIPPY, but it's sort of like asking for directions to City Hall and being provided directions to the City Library.
     
    elise_moss, Mar 18, 2005
    #12
  13. I want to be able to correspond some data from two text files...one txt
    What part of this is specific in saying you know how to do it...Nasty!
    This seem like the question to me since the other question is like falling
    off a log,
    or typing a period and looking for a second!!! You'll never get to City Hall
    this
    way...lost much?
     
    Paul Richardson, Mar 18, 2005
    #13
  14. Maybe you still are being snippy. It's not wise to piddle where you eat.
     
    Frank Oquendo, Mar 18, 2005
    #14
  15. BTW, I did indeed answer your question. What I did not do was provide
    complete instructions on how to implement the solution. If you require
    an additional level of detail, by all means: ask.

    I take exception with your characterization of my response as useless,
    pointless or just plain wrong simply because it did not come in
    bite-size chunks of code.
     
    Frank Oquendo, Mar 18, 2005
    #15
  16. itemno = List.ListIndex

    itemno should be a long or integer NOT an object
     
    Jorge Jimenez, Mar 19, 2005
    #16
  17. Oops. Sorry, I see you got your answer already.
     
    Jorge Jimenez, Mar 19, 2005
    #17
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.