Reading ProjectList text file(contains name of the projects) n display those lines into combobox
my above code ....it is reading only first line of text file

Private Sub Form_Load()

Open "c:\ProjectList.txt" For Random As #1 Len = Len(ReadData(1))

For intLoopIndex = 1 To LOF(1) / Len(ReadData(1))
    Get #1, , ReadData(intLoopIndex)
    cmbRead.AddItem (ReadData(intLoopIndex).NameofProject)   
Next intLoopIndex

Close #1

End Sub
8 Years
Discussion Span
Last Post by vb5prgrmr

To begin with, this is not a code snippet! It is a question!

Option Explicit
Private Sub ReadFileUpdateCombo()
Dim FName As String, FNumb As Integer
Dim LineContents As String

FName = "PathToFileandName"
FNumb = FreeFile

Open FName For Input As #FNumb
Do While Not EOF(FNumb)
  Line Input #FNumb, LineContents
  Combo1.AddItem LineContents

Close #FNumb
End Sub

Good Luck


To begin with, this is not a code snippet! It is a question!


Did you just hand the answer to them? After over 1000 posts you should know better than that. We help here. We are not a coding service.


Walt, search my handle and Open and you will see more often than not my suggest is to read in help about the following

FreeFile Function
Open Statement
Input Function or Line Input Function
Print Statement 'for writing out
Close Statement

But some days when I'm feeling charitable or when the OP has put forth the effort like this one has, you will see an answer like the above...

Have a nice day

Votes + Comments
I can live with that :o)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.