0

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:

3
Contributors
5
Replies
7
Views
11 Years
Discussion Span
Last Post by williamrojas78
0

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:

'after you read the line
Dim myArray As Array
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

0

if the text file data is seperate by symbol ":" then how i going to do

sample data
RX:12/3/06:SS1112:483720:E
RX:12/3/06:SS1113:483721:-E

0

Then you split the array when ":" is found.

'after you read the line
Dim myArray As Array
myArray = Split(line, ":")

regards

0

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

1

Hi,

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

myArray = Split(line, ":")

Dim i As Integer
dim val as 
For i = 0 To myArray.Length - 1
     val = myArray(i)                'read the value of the items in the array
     dg.Item(row, column) = val      'place it in the datagrid
Next

Dim myArray As Array

Hope it helps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.