Reading from a dat file

M

Mike

Could someon help me try to read a dat file with lines of text of this
format. If you paste this into a text file it show you what im dealing with.
Im not sure how to look for chr(166) and read whats between the chr

Any help would be great!!

0\ <Unknown PLU: >\ ¦1¦726224¦QUORUM NIC
TORO¦999.99¦22.92¦1¦¦0¦0.00¦¦<Unknown PLU: >¦999.99¦22.92¦0.00¦0.00¦¦
101\ ASHTRAY CERAMIC ASST \
808178020826¦44¦72031¦Ashtray-Assorted
Ceramic¦2.30¦6.90¦1¦¦101¦50.00¦808178020826¦ASHTRAY CERAMIC ASST
¦2.30¦6.90¦4.59¦4.59¦¦
104\ JOB 1.5 PAPERS 24PK BOX\ 079083157246¦1¦028381¦JOB 1.5
CIGT. PAPERS¦26.27¦25.22¦1¦¦104¦25.00¦079083157246¦JOB 1.5 PAPERS 24PK
BOX¦26.27¦25.22¦35.05¦35.05¦¦
104\ TOP ROLLING PAPER 24 BOX\ 077170510011¦1¦029926¦TOP CIGT
PAPERS¦15.74¦14.69¦1¦¦104¦25.00¦077170510011¦TOP ROLLING PAPER 24
BOX¦15.74¦14.69¦20.99¦20.99¦¦
 
J

Jacob Skaria

Mike, check out the below code..I have put some remarks along with the code

Sub Macro()

Dim intFile As Integer, strData As String, arrData As Variant

intFile = FreeFile

'Open file for reading
Open "d:\file1.dat" For Input As #intFile

'Loop until End of File
Do While Not EOF(intFile)

'Read one line
Line Input #intFile, strData

'Split the contents by Chr(166)
arrData = Split(strData, Chr(166))

'To retrive first field arrData(0)
'The below retrives field 3 726224 from the 1st line
MsgBox arrData(2)

Loop
Close #intFile


End Sub
 
M

Mike

Thanks Jacob I can work it out from there.

Jacob Skaria said:
Mike, check out the below code..I have put some remarks along with the code

Sub Macro()

Dim intFile As Integer, strData As String, arrData As Variant

intFile = FreeFile

'Open file for reading
Open "d:\file1.dat" For Input As #intFile

'Loop until End of File
Do While Not EOF(intFile)

'Read one line
Line Input #intFile, strData

'Split the contents by Chr(166)
arrData = Split(strData, Chr(166))

'To retrive first field arrData(0)
'The below retrives field 3 726224 from the 1st line
MsgBox arrData(2)

Loop
Close #intFile


End Sub
 
Top