Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21243

Open File to Load Listbox - should be easy

$
0
0
Hello, if someone could answer this I would appreciate it. I am trying to load multiple list boxes with the same file, but because of the nature I call the same procedure. After I load the first list box, I can't open the file again: error message "file already open". It should be closed at end of call, but I have no idea why it is not. Please help because I'm going crazy over this. Here is code.

Call Loadlistbox("C:\WBS.cip", Main.Webb)
Call Loadlistbox("C:\WBS.cip", Mini.WebbC)
Call Loadlistbox("C:\WBS.cip", Questions.Webb)

Public Sub Loadlistbox(Directory As String, TheList As ListBox)
Dim MyString As String
If Len(Dir(Directory)) < 1 Then
MsgBox "Error Opening List " & TheList
Exit Sub
End If
Open Directory$ For Input As #1
While Not EOF(1)
Input #1, MyString$
DoEvents
TheList.AddItem MyString$
Wend
Close #1
End Sub

extremely simple, but I can't figure it why it does not close so I can reopen. It must be done this way due to code will be changed for variable files and listboxes later.

Viewing all articles
Browse latest Browse all 21243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>