LER ARQUIVO TXT, E POR NO MSFLEXGRID OU DBGRID
Boa tarde, pessoal.
gostaria de ler um arquivo txt e lista o nosso numero e o valor num msflexgrid ou dbgrid.
exemplo do arquivo txt.
10400000 2127232920001700000000000000000000000558405660100000000SIND EMPREG COMER DE SOUSA C ECON FEDERAL 21110201002180700037204000000 RETORNO-PRODUCAO 000
10400011T0100030 20127232920001700000000000000000000000558405660100000000SIND EMPREG COMER DE SOUSA 00000372111020100000000000 00
1040001300001T 060000000566010000000 249000500000030961100000000000000007102010000000000007225000005580000000000000000 090000000000000000 000000000000161020101
1040001300002U 0600000000000000000000000000000000000000000000000000000000000000000000000722500000000000[txt-color=#e80000]7225[/txt-color]000000000000000000000000000000111020101310201000001310201000000000000000000000000000000000000000000000000000000000000000000000
1040001300003T 060000000566010000000 249000500000031089100000000000000014102010000000000003225748022160000000000000000 090000000000000000 000000000000326040101
1040001300004U 0600000000000000000000000000000000000000000000000000000000000000000000000322500000000000[[txt-color=#e80000]b]3225[/b][/txt-color]000000000000000000000000000000111020101310201000001310201000000000000000000000000000000000000000000000000000000000000000000000
1040001300005T 060000000566010000000 249000500000032190100000000000000012102010000000000003225000005580000000000000000 090000000000000000 000000000000161020101
1040001300006U 0600000000000000000000000000000000000000000000000000000000000000000000000322500000000000[txt-color=#e80000]3225[/txt-color]000000000000000000000000000000111020101310201000001310201000000000000000000000000000000000000000000000000000000000000000000000
10400015 00001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
10499999 000001000018
onde o numero em negrido preto e o NOSSO NUMERO e o numero em negrito vermelho e o VALOR.
Listando essas 2 informações num dbgrid ou msflexgrid sendo por LINHA O NOSSO NUMERO E O VALOR
gostaria de ler um arquivo txt e lista o nosso numero e o valor num msflexgrid ou dbgrid.
exemplo do arquivo txt.
10400000 2127232920001700000000000000000000000558405660100000000SIND EMPREG COMER DE SOUSA C ECON FEDERAL 21110201002180700037204000000 RETORNO-PRODUCAO 000
10400011T0100030 20127232920001700000000000000000000000558405660100000000SIND EMPREG COMER DE SOUSA 00000372111020100000000000 00
1040001300001T 060000000566010000000 249000500000030961100000000000000007102010000000000007225000005580000000000000000 090000000000000000 000000000000161020101
1040001300002U 0600000000000000000000000000000000000000000000000000000000000000000000000722500000000000[txt-color=#e80000]7225[/txt-color]000000000000000000000000000000111020101310201000001310201000000000000000000000000000000000000000000000000000000000000000000000
1040001300003T 060000000566010000000 249000500000031089100000000000000014102010000000000003225748022160000000000000000 090000000000000000 000000000000326040101
1040001300004U 0600000000000000000000000000000000000000000000000000000000000000000000000322500000000000[[txt-color=#e80000]b]3225[/b][/txt-color]000000000000000000000000000000111020101310201000001310201000000000000000000000000000000000000000000000000000000000000000000000
1040001300005T 060000000566010000000 249000500000032190100000000000000012102010000000000003225000005580000000000000000 090000000000000000 000000000000161020101
1040001300006U 0600000000000000000000000000000000000000000000000000000000000000000000000322500000000000[txt-color=#e80000]3225[/txt-color]000000000000000000000000000000111020101310201000001310201000000000000000000000000000000000000000000000000000000000000000000000
10400015 00001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
10499999 000001000018
onde o numero em negrido preto e o NOSSO NUMERO e o numero em negrito vermelho e o VALOR.
Listando essas 2 informações num dbgrid ou msflexgrid sendo por LINHA O NOSSO NUMERO E O VALOR
[ô]para ler o arquivo txt ...
DIM intFreeFile AS INTEGER
DIM strRegistro AS STRING
intFreeFile = FREEFILE
OPEN (ARQUIVO.TXT) FOR INPUT AS #intFreeFile
DO UNTIL EOF(intFreeFile)
LINE INPUT #intFreeFile, strRegistro
intLinha = msflexgrid.rows
msflexgrid .rows = intLinha + 1
msflexgrid.textmatrix(intLinha,1)= MID(strRegistro,?1,?2) [ô] ?1 é a posição inicial da informação nosso numero ?2 é o tamanho da informação nosso numero
msflexgrid.textMatrix(intLinha,2)= MID(strRegistro,?3,?4) [ô]?3 é a posição inicial da informação valor ?4 é o tamanho da informação valor
LOOP
CLOSE #intFreeFile
DIM intFreeFile AS INTEGER
DIM strRegistro AS STRING
intFreeFile = FREEFILE
OPEN (ARQUIVO.TXT) FOR INPUT AS #intFreeFile
DO UNTIL EOF(intFreeFile)
LINE INPUT #intFreeFile, strRegistro
intLinha = msflexgrid.rows
msflexgrid .rows = intLinha + 1
msflexgrid.textmatrix(intLinha,1)= MID(strRegistro,?1,?2) [ô] ?1 é a posição inicial da informação nosso numero ?2 é o tamanho da informação nosso numero
msflexgrid.textMatrix(intLinha,2)= MID(strRegistro,?3,?4) [ô]?3 é a posição inicial da informação valor ?4 é o tamanho da informação valor
LOOP
CLOSE #intFreeFile
Boa noite, Rapaz Não deu certo.
Opá Consegui, Muito Obrigado pela Ajuda.
Tópico encerrado , respostas não são mais permitidas