how to read data from text file into data grid???

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2006
Posts: 7
Reputation: ohohling is an unknown quantity at this point 
Solved Threads: 0
ohohling ohohling is offline Offline
Newbie Poster

how to read data from text file into data grid???

 
0
  #1
Aug 4th, 2006
i need to create a system to read the txt file data to datagrid
but i just know read by line.

that say the sample.txt file pettern as below:

date time price
1/8 2:15pm $5.00
2/8 3:20pm $6.00

how i going to fill the data separate by date, time, and price??
means read by row n column....n fill into datagrid....
thanks....

if got sample to show then will be more better....:lol:
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 85
Reputation: williamrojas78 is an unknown quantity at this point 
Solved Threads: 4
williamrojas78's Avatar
williamrojas78 williamrojas78 is offline Offline
Junior Poster in Training

Re: how to read data from text file into data grid???

 
0
  #2
Aug 4th, 2006
Hi

It looks like you have a set of " " between the columns, so what i would do is split each line one at a time, something like this:

  1.  
  2.  
  3. 'after you read the line
  4. Dim myArray As Array
  5. myArray = Split(line, " ")

that will create an array with the data what you want. Probably you will have to trim each line to get rid of the empty spaces.

Hope it helps

Regards
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 7
Reputation: ohohling is an unknown quantity at this point 
Solved Threads: 0
ohohling ohohling is offline Offline
Newbie Poster

Re: how to read data from text file into data grid???

 
0
  #3
Aug 6th, 2006
if the text file data is seperate by symbol ":" then how i going to do

sample data
RX:12/3/06S1112:483720:E
RX:12/3/06S1113:483721:-E
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 85
Reputation: williamrojas78 is an unknown quantity at this point 
Solved Threads: 4
williamrojas78's Avatar
williamrojas78 williamrojas78 is offline Offline
Junior Poster in Training

Re: how to read data from text file into data grid???

 
0
  #4
Aug 7th, 2006
Then you split the array when ":" is found.

  1.  
  2. 'after you read the line
  3. Dim myArray As Array
  4. myArray = Split(line, ":")

regards
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1
Reputation: cheehongjb is an unknown quantity at this point 
Solved Threads: 0
cheehongjb cheehongjb is offline Offline
Newbie Poster

Re: how to read data from text file into data grid???

 
0
  #5
Mar 13th, 2008
Dear williamrojas78, ohohling
may i know how to read the data from the array?

after assign the txt line into the array by the code above. how can i take 1 by 1 and put it into datagrid?

thanks a lot
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 85
Reputation: williamrojas78 is an unknown quantity at this point 
Solved Threads: 4
williamrojas78's Avatar
williamrojas78 williamrojas78 is offline Offline
Junior Poster in Training

Re: how to read data from text file into data grid???

 
0
  #6
Mar 19th, 2008
Hi,

Here it is; first you read the array, then you read line by line and after that you place it in the grid.

  1. myArray = Split(line, ":")
  2.  
  3. Dim i As Integer
  4. dim val as
  5. For i = 0 To myArray.Length - 1
  6. val = myArray(i) 'read the value of the items in the array
  7. dg.Item(row, column) = val 'place it in the datagrid
  8. Next
Dim myArray As Array

Hope it helps
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC