How do I input data from a text file into a combo box?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • J Adams

    How do I input data from a text file into a combo box?

    I am trying to get the data in personal customer infomation.txt into a combo box, any ideas where i am going wrong?

    Code:
    Private Sub Cmbamend_Change()
    Dim persdatafile As String
    Dim persdata As String
    
    persdatafile = App.Path & "\Personal Customer Infomation.txt"
        Open persdatafile For Input As #1
       
    Do While Not EOF(1)
        Input #1, persdata
    Loop
    Close #1
    
    Cmbamend = persdata
    
    End Sub
    Last edited by NeoPa; Nov 17 '10, 08:12 PM. Reason: Code Tags
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    "Input" reads only line by line!
    So only the last line is in persdata.
    You have to add line by line in the combobox with:
    Code:
    Do While Not EOF(1)
        Input #1, persdata
        Cmbamend.AddItem persdata
    Loop
    And not: Cmbamend = persdata

    Comment

    Working...