473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Listbox

Hello All,

I have a listbox that I want to populate with information from a text file.
For each index in the listbox, I want to load the next line of the text
file, until there are no more lines. I have the code to open and read each
line from the text file, but I cannot figure out a way to read a line, put
it into the listbox, then go to the next line and repeat the process. I know
it will have to use a For... Next loop, but can't get the configuration
right. Any help would be greatly appreciated!
Jul 17 '05 #1
2 5445
> I have a listbox that I want to populate with information from a text
file.
For each index in the listbox, I want to load the next line of the text file, until there are no more lines. I have the code to open and read each line from the text file, but I cannot figure out a way to read a line, put it into the listbox, then go to the next line and repeat the process. I know it will have to use a For... Next loop, but can't get the configuration right. Any help would be greatly appreciated!


Usually it is a good idea to post the code that is not working as you
expect (or that you have so far). That way, we can adapt our answers to
your style of programming or even make suggestions of ways we might
approach the problem differently. Without seeing your code, the best we
can do is give you code and hope it makes sense to you or, if it
doesn't, that you will try and read up on the parts that are unfamiliar
to you.

Dim FF As Long
Dim LineOfText As String
FF = FreeFile
Open "c:\temp\Bi-Weekly Work Schedule (2009).txt" For Input As #FF
Do While Not EOF(FF)
Line Input #FF, LineOfText
' If test makes sure you don't add a blank line
If Len(LineOfText) Then List1.AddItem LineOfText
Loop
Close #FF

Rick - MVP

Jul 17 '05 #2
That's exactly what I needed, thanks!

-Eric

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:Us********************@comcast.com...
I have a listbox that I want to populate with information from a text

file.
For each index in the listbox, I want to load the next line of the

text
file, until there are no more lines. I have the code to open and read

each
line from the text file, but I cannot figure out a way to read a line,

put
it into the listbox, then go to the next line and repeat the process.

I know
it will have to use a For... Next loop, but can't get the

configuration
right. Any help would be greatly appreciated!


Usually it is a good idea to post the code that is not working as you
expect (or that you have so far). That way, we can adapt our answers to
your style of programming or even make suggestions of ways we might
approach the problem differently. Without seeing your code, the best we
can do is give you code and hope it makes sense to you or, if it
doesn't, that you will try and read up on the parts that are unfamiliar
to you.

Dim FF As Long
Dim LineOfText As String
FF = FreeFile
Open "c:\temp\Bi-Weekly Work Schedule (2009).txt" For Input As #FF
Do While Not EOF(FF)
Line Input #FF, LineOfText
' If test makes sure you don't add a blank line
If Len(LineOfText) Then List1.AddItem LineOfText
Loop
Close #FF

Rick - MVP

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
3
by: Paul T. Rong | last post by:
I have a listbox (of product names) control on my form. I want to pass the selected item (a product name) to a subform, and the product unitprice should apear automatically next to the product name...
8
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
3
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.