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
help......

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

Recommended Answers

All 3 Replies

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
Loop

Close #FNumb
End Sub

Good Luck

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

snipped

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

commented: I can live with that :o) +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.