If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Pulling data from a text file???

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-21-04, 12:38
Jane2004 Jane2004 is offline
Registered User
 
Join Date: Feb 2004
Posts: 7
Pulling data from a text file???

Hi everyone,
I have a text file saved in the Bin-folder. It has several lines of comma-delimited record: ID, Lastname, Firstname, Grade.
ID as integer, LAstname/Firstname as strings and grade as double.
I want my form to pull those data up and insert the four items into four arrays.
The file should be read one line at a time until the end. After the file is read it should display the four arrays created into four columns.


Any ideas?!?! I have no clue... :-(
Please help!
Reply With Quote
  #2 (permalink)  
Old 02-22-04, 17:27
brianb99999 brianb99999 is offline
Registered User
 
Join Date: Feb 2004
Posts: 37
Hi,

Dont have time to describe it properly, but:
1. you need to create a type in a module and dimensionalise this type as an array (having four arrays for 1 record is a bad idea).
2. You need to get the path where the file is from the user (I prefer to use the commondialog control for this (in components select Microsoft Common Dialog Control 6.0).
3. You need to use the freefile command (intfilehandle = freefile).
4. You need to use the open command (open {filename} for input as #intfilehandle).
5. In a loop (do while not EOF(intfilehandle)), use line input to get the data (line input #intfilehandle, strinput)
6. In the loop you need to parse the input and return it to the type array.
7. In the loop you need to validate the input
8. After the loop you need to close the file (close #intfilehandle)
9. Display the results from the type as you see fit.

If you still have trouble, send me an e-mail at brianb@telpacific.com.au (subject it something like, can you help with VB as I get a lot of junk mail) and I might be able to send you some old code for steps 1 -8 (step 9 is up to you, though I would recommend reasearching how to use the flexgrid or datagrid controls).

Brian.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On