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:

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

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

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

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

regards

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.