ARQUIVO TEXTO

JUNIOR.STATUS 23/09/2010 10:43:03
#353654
bom dia, amigos

tenho um txt onde tem varios nomes em cada linha separados por ;

como faço pra colocalos em uma unica coluna pode ate ser em outro TXT


grato

THIGO 23/09/2010 11:12:23
#353660
amigo veja se eu entendi direito você quer fazer dessa maneira conforme o exemplo.

Teste;Teste;Teste;Teste;Teste;Teste

Quer que fica assim...
Teste;
Teste;
Teste;
Teste;

Se for assim voce pode varrer esse arquivo txt e jogar num listbox ou textbox.
Ah esse arquivo txt tem limite de nomes exemplo 30 nomes por arquivo separado por ; ou não
Se não tiver vocÊ terá que fazer um contador de quantos ; tem no arquivo e usar essa função que vou te passar.

[ô]**********************************************
[ô]função de procura de um registro em uma string Por TRS
[ô]**********************************************
Public Function strCampo(ByVal record$, separator$, fieldnumber%) As String
Dim strfield$
Dim intA As Integer
Dim strB As String
Dim intY As Integer
[ô] Dim X
Dim strC As String
Dim intZ As Integer

If Len(record$) = 0 Then [ô]return null if zero length string
strfield$ = [Ô][Ô]
Exit Function
End If

If InStr(record$, separator$) = 0 Then [ô]return null if less than two fields
strfield$ = [Ô][Ô]
Exit Function
End If

If fieldnumber% < 1 Then [ô]return null if requested field number is not positive
strfield$ = [Ô][Ô]
Exit Function
End If

For intA = 1 To Len(record$) [ô]count separators for next evaluation
strB = Mid$(record$, intA, 1)
If strB = separator$ Then
intY = intY + 1
End If
Next intA

If intY < (fieldnumber% - 1) Then [ô]return null if non-existent field is requested
strfield$ = [Ô][Ô]
Exit Function
End If

For intA = 1 To Len(record$) [ô]parse requested field from record
strC = Mid$(record$, intA, 1)
If strC = separator$ Then
intZ = intZ + 1
If intZ = (fieldnumber% - 1) Then
record$ = Right$(record$, Len(record$) - intA)
End If
End If
Next intA

If InStr(record$, separator$) = 0 Then [ô]if no separators left in record, then remaining record IS the
strCampo = record$ [ô]requested field (last)
Else
strCampo = Left$(record$, InStr(record$, separator$) - 1)
End If

End Function


Essa é a função para usar e simples basta usar o exemplo abaixo assim que ler o arquivo e pegar a string inteira e saber a quantidade de ; que tem

dim strNome as string

For i = 1 to qtd
[ô]Ae você joga na variavel strnome e preenche em coluna aonde voce quer se é num textbox ou listbox
strnome = strCampo(strLinhaArquivoTxt, [Ô];[Ô], i)

[ô]i significa o loop da quantidade de ; que tem no arquivo por linha beleza
next


Espero ter ajudado, acho que isso ae qualquer duvida pergunta ae
GERARDA 23/09/2010 20:35:42
#353710
Resposta escolhida
veja esse exemplo ve se te ajuda
JUNIOR.STATUS 24/09/2010 09:01:54
#353736
é isso mesmo ...mto obrigado GERARDA

Tópico encerrado , respostas não são mais permitidas