Aspen2K
10-04-2001, 12:23 PM
I'm having troubles trying to load from a text file back into a list box. The code below for loading actually works if there is only 3 items in the listbox upon saving when program last exited, however if there are more or less entries it don't work. So my question is, when loading how do I determine in code how many lines are to be added ? I tried somthing like For i = 0 to EOF but it did not work. Whats the dilly ? Thank you
Dim I as Integer
Dim strEntry as String
Private Sub CmdSaveLst_Click()
ff = FreeFile(0)
Open "C:\WINDOWS\Desktop\data.txt" For Output As #ff
For i = 0 To List2.ListCount - 1
strEntry = List2.List(i)
Print #ff, strEntry
Next i
Close ff
End Sub
Private Sub Form_Load()
ff = FreeFile(0)
Open "C:\WINDOWS\Desktop\data.txt" For Input As #ff
For i = 0 To 2 <font color=green>' Part In Question</font color=green>
Input #ff, strEntry
List2.List(i) = strEntry
Next i
Close ff
End Sub
Dim I as Integer
Dim strEntry as String
Private Sub CmdSaveLst_Click()
ff = FreeFile(0)
Open "C:\WINDOWS\Desktop\data.txt" For Output As #ff
For i = 0 To List2.ListCount - 1
strEntry = List2.List(i)
Print #ff, strEntry
Next i
Close ff
End Sub
Private Sub Form_Load()
ff = FreeFile(0)
Open "C:\WINDOWS\Desktop\data.txt" For Input As #ff
For i = 0 To 2 <font color=green>' Part In Question</font color=green>
Input #ff, strEntry
List2.List(i) = strEntry
Next i
Close ff
End Sub