|
-
May 7th, 2006, 01:09 AM
#1
Thread Starter
Frenzied Member
How to populate listbox with data from access and text file
Hi all. Could any one show me how i can populate a listbox with data from ms access db and text file.Thanks
-
May 7th, 2006, 03:00 AM
#2
Fanatic Member
Re: How to populate listbox with data from access and text file
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
Dont rely only on your luck. Work hard until You get success.
vb Code:
Private sub Time_ispassing
While Me.Notgetsuccess
trygain=tryagain+1
Me.workhard
wend
end sub
-
May 7th, 2006, 03:13 AM
#3
Thread Starter
Frenzied Member
Re: How to populate listbox with data from access and text file
Thank u for u reply. It does not work. all i see the scroller moving for ever and no data is shown in listbox!!
-
May 7th, 2006, 03:18 AM
#4
Fanatic Member
Re: How to populate listbox with data from access and text file
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.
Dont rely only on your luck. Work hard until You get success.
vb Code:
Private sub Time_ispassing
While Me.Notgetsuccess
trygain=tryagain+1
Me.workhard
wend
end sub
-
May 7th, 2006, 03:38 AM
#5
Thread Starter
Frenzied Member
Re: How to populate listbox with data from access and text file
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 ?
-
May 7th, 2006, 03:52 AM
#6
Re: How to populate listbox with data from access and text file
How many lines are in your text file?
Can you post your file?
-
May 7th, 2006, 03:59 AM
#7
Thread Starter
Frenzied Member
Re: How to populate listbox with data from access and text file
 Originally Posted by lintz
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 . Thanks
-
May 7th, 2006, 04:01 AM
#8
Re: How to populate listbox with data from access and text file
that's what App.Path means
-
May 7th, 2006, 04:25 AM
#9
Fanatic Member
Re: How to populate listbox with data from access and text file
Yes that is what u had to odo. Please rate my post.
Dont rely only on your luck. Work hard until You get success.
vb Code:
Private sub Time_ispassing
While Me.Notgetsuccess
trygain=tryagain+1
Me.workhard
wend
end sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|