Wow thanks, you guys are really fast lol.
um i have two forms. the second form is the information where you write it down and then it saves to a text file.
the first form is the one that im having problems with.
1) i have a lstbox that i want to upload the data saved on the text file, but it just wont work.
CODE
'load the contents of listitems.txt into lstItems
Call LoadListFromFile(Application.Path & "\Stock.txt", lstProducts)
On Error GoTo ErrEvt
Dim TextLine As String, FN As Integer
Dim ProductList As String
Dim SourceFile As String
ProductList = lstProducts.Text
SourceFile = "Stock.Text"
FN = FreeFile()
Open SourceFile For Input As #FN ' Open file.
Do While Not EOF(FN) ' Loop until end of file.
Line Input #FN, TextLine ' Read line into variable.
If TextLine <> LineToRem Then
ProductList.AddItem(TextLine)
End If
Loop
Close(FN) ' Close file.
Exit Sub 'this error handler will skip the nasty problem
'if your text file isnt conformed with an extra linebreak at the end
'to avoid saying INPUT PAST EOF
ErrEvt:
Select Case Err.Number
Case 51
Err.Clear() ' just bail out from this
Case Else ' do nothing
End Select
Resume Next
im completely lost