Hi all. Could any one show me how i can populate a listbox with data from ms access db and text file.Thanks
Printable View
Hi all. Could any one show me how i can populate a listbox with data from ms access db and text file.Thanks
Try this:
VB Code:
Private Sub commandLoad_click() Dim sText As String Dim X As Integer X = FreeFile On Error Resume Next Open App.Path & "/textfilename.txt" For Input As #X While Not EOF(X) Input #X, sText$ List1.AddItem sText$ ' adds in to listbox1 DoEvents Wend Close #X End Sub
Thank u for u reply. It does not work. all i see the scroller moving for ever and no data is shown in listbox!!
It happens when the file does not contain any data. The should be a data in a etxt file like this:
254
ngng
fbhfbn
fbbf
fb
b356.
Try It.
well my file has data line by line and i tried u data too and it did not work!! Do i need any refrences or components or change in listbox property? i place the text file in c:\ do i need to put c:\ in the path too ?
How many lines are in your text file?
Can you post your file?
oh got it working i had to put the text file in same folder as vb project is . ThanksQuote:
Originally Posted by lintz
that's what App.Path means :)
Yes that is what u had to odo. Please rate my post.