Postada em 05/11/2004 14:19 hs
Ola amigos.
Estou no servico apanhando muito para saber como fazer que um arquivo bdf se converta em txt. Jah esta tudo feito, o problema eh que ele esta repitindo os dados da tabela, nao esta passando para o proximo registro e fazendo tudo em uma linha só, aqui esta o codigo
Set Conn = New ADODB.Connection SQLConn = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=21;Dbq=" & Caminho Conn.Open SQLConn SQL = "SELECT * FROM " & Text2.text Set rsDarf = New ADODB.Recordset 'rsDarf.CursorLocation = adUseServer rsDarf.CursorType = adOpenForwardOnly rsDarf.LockType = adLockOptimistic rsDarf.Open SQL, Conn, , , adCmdText vArqTexto = CurDir$ & "" & Text2.text & ".txt" Open vArqTexto For Output As #1 While Not rsDarf.EOF
If Not IsNull(rsDarf.Fields("Telefone")) Then 'vTexto = rsDarf.Fields("TeleFone") + ";" + Space(8) vTexto = vTexto + Left(rsDarf.Fields("Telefone") + Space(8), 10) rsDarf.MoveNext End If If IsNull(rsDarf.Fields("Telefone")) Then vTexto = Left(rsDarf.Fields("tenefone") + Space(8), 10) rsDarf.MoveNext End If If Not IsNull(rsDarf.Fields("Cidade")) Then vTexto = vTexto + Left(rsDarf.Fields("Cidade") + Space(30), 30) rsDarf.MoveNext End If If IsNull(rsDarf.Fields("cidade")) Then vTexto = vTexto + Left(rsDarf.Fields("Nome") + Space(30), 30) rsDarf.MoveNext End If If Not IsNull(rsDarf.Fields("Nome")) Then vTexto = vTexto + Left(rsDarf.Fields("Nome") + Space(20), 20) rsDarf.MoveNext End If If IsNull(rsDarf.Fields("Nome")) Then vTexto = vTexto + Left(rsDarf.Fields("Nome") + Space(20), 20) rsDarf.MoveNext End If If Not IsNull(rsDarf.Fields("Endereco")) Then 'vTexto = vTexto + rsDarf.Fields("Endereco") + ";" + Space(60) vTexto = vTexto + Left(rsDarf.Fields("Endereco") + Space(60), 60) rsDarf.MoveNext End If If IsNull(rsDarf.Fields("Endereco")) Then vTexto = vTexto + Left(rsDarf.Fields("Endereco") + Space(60), 60) rsDarf.MoveNext End If If Not IsNull(rsDarf.Fields("CPF")) Then ''''vTexto = vTexto + rsDarf.Fields("CPF") + ";" vTexto = vTexto + Left(rsDarf.Fields("CPF") + Space(14), 14) rsDarf.MoveNext End If If IsNull(rsDarf.Fields("CPF")) Then vTexto = vTexto + Left(rsDarf.Fields("CPF") + Space(14), 14) ''''vTexto = vTexto + Left(rsDarf("CPF") + Space(14), 14) rsDarf.MoveNext End If If Not IsNull(rsDarf.Fields("CEP")) Then ''''vTexto = vTexto + rsDarf.Fields("CEP") + ";" vTexto = vTexto + Left(rsDarf.Fields("CEP") + Space(8), 8) rsDarf.MoveNext End If If IsNull(rsDarf.Fields("CEP")) Then vTexto = vTexto + Left(rsDarf.Fields("CEP") + Space(8), 8) ''''vTexto = vTexto + Left(rsDarf("Nome") + Space(60), 60) rsDarf.MoveNext End If If Not IsNull(rsDarf.Fields("Bairro")) Then ''''vTexto = vTexto + rsDarf.Fields("Bairro") + ";" vTexto = vTexto + Left(rsDarf.Fields("Bairro") + Space(20), 20) rsDarf.MoveNext End If If Not IsNull(rsDarf.Fields("DDD")) Then ''''vTexto = vTexto + rsDarf.Fields("DDD") vTexto = vTexto + Left(rsDarf.Fields("Nome") + Space(4), 4) rsDarf.MoveNext End If If IsNull(rsDarf.Fields("DDD")) Then vTexto = vTexto + Left(rsDarf.Fields("Nome") + Space(4), 4) rsDarf.MoveNext End If Print #1, vTexto vAtual = vAtual + 1 vTotal = vTotal + 1 Label1.Caption = "Lendo Registro " & Format(vAtual, "#########0") & " de " & Format(vTotal, "#########0") DoEvents rsDarf.MoveNext Wend
Abracos
|