Fórum Erro em gerar parcelas... #269277
18/02/2005
0
var
v_count,v_parc: integer;
v_date:Tdatetime;
v_valor:REAL;
begin
Table2.Edit;
Table2Valor.value := edvalor.text;
Table2Parcelas.value := edparcela.Text;
Table2DataCad.Value := formatDateTime(´dd/mm/yyyy´,Date);
Table2Tipo.Value := ´C´;
Table2.Refresh;
v_date:=strtodate(eddata.text)+ strtofloat(ComboBox2.text);
v_count:=strtoint(edparcela.text);
v_parc:=1;
Query1.Open;
while v_count>0 do
begin
Query1.insert;
Query1.FieldByName(´QuantParcelas´).asinteger:=(v_parc);
V_VALOR:=((strtofloat(edvalor.text)-strtofloat(edentrada.text)))/strtoint((edparcela.text));
query1.fieldbyname(´valor´).value:=formatfloat(´ ,#,,0.00´,v_Valor);
query1.FieldByName(´Vencimento´).asdatetime:=v_date;
Query1CodControle.value := Table2CodSistema.value;
Query1Endereco.value := Table2Endereco.Value;
Query1Nome.value := Table2Nome.Value;
Query1Complemento.value := Table2Complemento.value;
Query1Bairro.value := Table2Bairro.value;
Query1Cidade.value := Table2Cidade.Value;
Query1UF.value := Table2UF.value;
Query1CPFCNPJ.value := Table2CPFCNPJ.value;
Query1Discricao.value := Table2Discricao.value;
Query1DATA_CAD.Value := formatDateTime(´dd/mm/yyyy´,Date);
Query1CodAcess.Value := Table1Codigo.value;
Query1.post;
v_count:=v_count-1;
v_parc:=v_parc+1;
v_date:=v_date+30;
query1.next;
Gigatel
Curtir tópico
+ 0Posts
18/02/2005
Lindomar.des
Para vc ver em qual linha está ocorrendo o erro use debug, mas pelo código q vc postou o erro pode estar nessa linha:
V_VALOR:=((strtofloat(edvalor.text)-strtofloat(edentrada.text)))/strtoint((edparcela.text));
ou em qualquer outra onde vc está convertendo um valor texto em float no qual está armazenado o valor acima de 999,99.
tive este problema recentemente, valores acima de 999,99 acontecia esse erro que corrigi usando, no meu caso, o campo da tabela.
resumindo, vc tem uma valor ´1.000,00´ se vc usar:
variavel := strtofloat(´1.000,00´) irá dar o erro mas se vc usar:
variavel := strtofloat(´1000,00´) não dará o erro.
vc pode usar uma rotina para retirar o ponto de separação de milhar do texto que vc estiver utilizando.
espero ter ajudado.
Gostei + 0
19/02/2005
Gigatel
variavel := strtofloat(´1.000,00´) irá dar o erro mas se vc usar:
variavel := strtofloat(´1000,00´) não dará o erro.
Como eu resolveria isso ?
Gostei + 0
19/02/2005
Lindomar.des
Você pode usar uma função para retirar o ponto. Qunado preciso uso esta:
function RetirarPonto(strSrc: string): string;
var
StrAux: string;
i: integer;
FlagFim: boolean;
begin
i := 1;
FlagFim := false;
StrAux := StrSrc;
while (not FlagFim) do
begin
if StrAux[i] = ´.´ then
begin
Delete(StrAux, i, 1);
end
else
begin
i := i + 1;
end;
if i > length(StrAux) then
flagFIm := true;
end;
RetirarPonto := StrAux;
end;
Chamando a função:
variavel := strtofloat(RetirarPonto(´1.000,00´)) ;
Espero ter ajudado.
Gostei + 0
19/02/2005
Gigatel
O evento Onexit coloquei isto...
edvalor.Text:= format(´¬n´, [strtofloat(edvalor.Text)]);
aí quando coloco algum número acima de 1.000,00 dá problema...
como poderia consertar isto ?...
o erro que dá é este..
1.000,00 is not valid floating point value
..no caso aí e quando o valor é 1.000,00..más poder outros...
Gostei + 0
19/02/2005
Lindomar.des
Seguindo a função que passei use:
edvalor.Text:= format(´¬n´, [strtofloat(RetirarPonto(edvalor.Text))]);
Gostei + 0
19/02/2005
Gigatel
um função mt grande para uma coisa bem pequena..mais estou na luta vou fazer o que o colega sugeriu...
Gostei + 0
20/02/2005
Gigatel
Curioso não funcionol... continua dando problema...
Gostei + 0
20/02/2005
Gigatel
Curioso não funcionol... continua dando problema...[/quote:bcde09b16b]
o problema e que o ponto não sai...
Gostei + 0
21/02/2005
Lindomar.des
O ponto não sai mesmo, visualmente, mas o erro tb não acontece. Isso se dá pelo fato de que o valor passado para a função StrToFloat é 1000,00 e não 1.000,00. A função ´RetirarPonto´ envia para a função StrToFloat o valor sem o ponto.
Se vc quiser mostrar o valor sem ponto no edit use:
edvalor.Text:= RetirarPonto(edvalor.Text);
ao invés de:
edvalor.Text:= format(´¬n´, [strtofloat(RetirarPonto(edvalor.Text))]);
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)