Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 11-06-2018
benegas benegas is offline
Registrado
NULL
 
Registrado: jun 2018
Posts: 5
Poder: 0
benegas Va por buen camino
Error: "is not a valid floating point value"

Caros Colegas buenas noches,
estoy com um problema com delphi 7 ,
el programa ejecuta pero al calcular aparece un error,
"is not a valid floating point value"

alguna idea ?
Responder Con Cita
  #2  
Antiguo 11-06-2018
ArtPortEsp ArtPortEsp is offline
Miembro
 
Registrado: may 2018
Ubicación: Mexico
Posts: 147
Poder: 6
ArtPortEsp Va por buen camino
Cita:
Empezado por benegas Ver Mensaje
Caros Colegas buenas noches,
estoy com um problema com delphi 7 ,
el programa ejecuta pero al calcular aparece un error,
"is not a valid floating point value"

alguna idea ?
No nos das muchos datos para ayudarte....

el error es por que estas tratando de hacer una operación con un dato que se espera como numérico (float) y no lo es... pero no hay mucho mas por decirte con tan pocos datos.
Responder Con Cita
  #3  
Antiguo 11-06-2018
benegas benegas is offline
Registrado
NULL
 
Registrado: jun 2018
Posts: 5
Poder: 0
benegas Va por buen camino
Código Delphi [-]

procedure TForm1.Button7Click(Sender: TObject);
var
  a,b,c,tpro,des,cot,inc,tpom,t,tpgs:real;
begin
  des:=strtofloat (descuento.text);
  inc:=strtofloat(incremento.Text);
  a:=strtofloat(encomienda.text);
  b:=strtofloat(viatico.text);
  c:=strtofloat(gastoadm.text);
  tpro:=strtofloat(total.text);
  t:= a+b+c+tpro;

  if (descuento.Enabled=true) then
  
    tpgs:= t-des;

  if(incremento.enabled=true) then
   begin
    tpgs:= t+inc;
   end;
  
  tp.text:= floattostr(tpgs);  aca me indica el error
  cot:= strtofloat(cotiza.text);
  tpom:= tpgs/cot;
  tpotra.text:=floattostr(tpom);
  
end;

end.

Última edición por Neftali [Germán.Estévez] fecha: 11-06-2018 a las 16:29:19.
Responder Con Cita
  #4  
Antiguo 11-06-2018
Avatar de ElKurgan
[ElKurgan] ElKurgan is offline
Miembro Premium
 
Registrado: nov 2005
Posts: 1.232
Poder: 20
ElKurgan Va camino a la fama
Probando tu código no me da ningún error y se ejecuta bien.

Por tanto, pienso que el error no es la llamada a la función, sino los datos que metes en las cajas de texto.

Por ejemplo, según la configuración regional que tengas, le debes poner el valor con la coma o con el punto como separador decimal.

En mi caso, la coma decimal me ha servidor bien.

También puedes probar la versión extendida de FloatToStr, en la que le pasas el "FormatSettings", para que no tengas errores con el separador decimal...

Aquí puedes ver más información:

Un saludo

Última edición por ElKurgan fecha: 11-06-2018 a las 10:05:15.
Responder Con Cita
  #5  
Antiguo 11-06-2018
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.021
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
benegas, bienvenido a clubdelphi, como siempre aconsejamos a los nuevos, no olvides leer nuestra guía de estilo, gracias por tu colaboración


Y recuerda poner los tags al código fuente, ejemplo:



Gracias

Además, debes poner títulos descriptivos a tu pregunta, porque "Ayuda Urgente" no permite saber nada sobre lo que trata el hilo que has creado.
Te lo he cambiado por: Error: "is not a valid floating point value"
Saludos.
Responder Con Cita
  #6  
Antiguo 11-06-2018
benegas benegas is offline
Registrado
NULL
 
Registrado: jun 2018
Posts: 5
Poder: 0
benegas Va por buen camino
aqui tienes el codigo completo. tambien pense en os separador decimal, pero no lo estoy usando. ybual da em mismo error

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Mask;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    MaskEdit1: TMaskEdit;
    Label4: TLabel;
    Combo1: TComboBox;
    Label5: TLabel;
    cotiza: TEdit;
    Label6: TLabel;
    lista: TListBox;
    lista2: TListBox;
    GroupBox1: TGroupBox;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    encomienda: TEdit;
    viatico: TEdit;
    gastoadm: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Label7: TLabel;
    total: TEdit;
    GroupBox2: TGroupBox;
    radio1: TRadioButton;
    Radio2: TRadioButton;
    GroupBox3: TGroupBox;
    Label8: TLabel;
    Label9: TLabel;
    descuento: TEdit;
    incremento: TEdit;
    Label10: TLabel;
    Label11: TLabel;
    tp: TEdit;
    tpotra: TEdit;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure CheckBox3Click(Sender: TObject);
    procedure Combo1Change(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure radio1Click(Sender: TObject);
    procedure Radio2Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
valor: string;
i: integer;
begin
i:=1;
  while (i<=4) do
    begin
      valor:=inputbox('Productos','Ingrese Productos','Ingresar');
      lista.items.add(valor);
      i:= i+1;
      end;

end;

procedure TForm1.Button6Click(Sender: TObject);
begin
if application.MessageBox('DESEA SALIR ?',
  'ATENCION !!!', MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2) = IDYES THEN
  close;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
num: string;
var
  s, pre: real;
i:integer;
begin
i:= 1;
  while (i<=4) do
    begin
      num:=inputbox('Precio','Ingrese Precio','Ingresar');
      lista2.Items.Add(num);
      pre:= strtofloat(num);
      s:= s+pre;
      i:= i+1;
      end;
      total.text:= floattostr(s);

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if lista.ItemIndex= -1 then
  begin
  showmessage('Seleccionar un Item');
  exit;
  end;
  lista.Items.Delete(lista.ItemIndex);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
if lista2.ItemIndex= -1 then
  begin
  showmessage('Seleccionar un Item');
  exit;
  end;
  lista2.Items.Delete(lista2.ItemIndex);
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
var
  e:real;
begin
  if CheckBox1.checked = true then
    begin
      e:=30000;
      encomienda.Color:=clWhite;
      encomienda.text:=floattostr(e);

    end
  else if CheckBox1.checked = false then
    begin
      encomienda.Color:=clYellow;
      encomienda.text:=' ';
    end;

end;

procedure TForm1.CheckBox2Click(Sender: TObject);
var
  v:real;
begin
  if CheckBox2.checked = true then
    begin
      v:=50000;
      viatico.Color:=clWhite;
      viatico.text:=floattostr(v);

    end
  else if CheckBox2.checked = false then
    begin
      viatico.Color:=clYellow;
      viatico.text:='';
    end;

end;

procedure TForm1.CheckBox3Click(Sender: TObject);
var
  g:real;
begin
  if CheckBox3.checked = true then
    begin
      g:=10000;
      gastoadm.Color:=clWhite;
      gastoadm.text:=floattostr(g);
    end
  else if CheckBox3.checked = false then
    begin
      gastoadm.Color:=clYellow;
      gastoadm.text:='';
    end;
end;

procedure TForm1.Combo1Change(Sender: TObject);
var
  n:integer;
begin
  n:= combo1.ItemIndex;
  if (n = 0) then
    cotiza.Text:= '5500';
  if (n = 1) then
    cotiza.Text:= '1500';

end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  combobox1.Text:= ' ';
  combobox2.Text:= ' ';
  maskedit1.Text:= ' ';
  combo1.Text:= ' ';
  cotiza.Text:= ' ';
  lista.clear;
  lista2.clear;
  CheckBox1.Checked := false;
  CheckBox2.Checked := false;
  CheckBox3.Checked := false;
  radio1.checked := true;
  radio2.checked := false;
  total.text:= ' ';
  descuento.Text:= ' ';
  incremento.text:= ' ';
  tp.Text:= ' ';
  tpotra.Text:= ' ';
  combobox1.SetFocus;
end;

procedure TForm1.radio1Click(Sender: TObject);
begin
  if (radio1.Checked=true) then
    begin
      descuento.Enabled:= true;
      descuento.Color:=clWhite;
      incremento.enabled:= false;
      incremento.Color:=clYellow;
      end;
end;

procedure TForm1.Radio2Click(Sender: TObject);
begin
  if (radio2.Checked=true) then
    begin
      descuento.Enabled:= false;
      descuento.Color:=clYellow;
      incremento.Enabled:= true;
      incremento.Color:=clWhite;
      end;
end;

procedure TForm1.Button7Click(Sender: TObject);
var
  a,b,c,tpro,des,cot,inc,tpom,t,tpgs:real;
begin
  des:=strtofloat (descuento.text);
  inc:=strtofloat(incremento.Text);
  a:=strtofloat(encomienda.text);
  b:=strtofloat(viatico.text);
  c:=strtofloat(gastoadm.text);
  tpro:=strtofloat(total.text);
  t:= a+b+c+tpro;

  if (descuento.Enabled=true) then
  
    tpgs:= t-des;

  if(incremento.enabled=true) then
   begin
    tpgs:= t+inc;
   end;
  
  tp.text:= floattostr(tpgs);
  cot:= strtofloat(cotiza.text);
  tpom:= tpgs/cot;
  tpotra.text:=floattostr(tpom);
  
end;

end.
Responder Con Cita
  #7  
Antiguo 11-06-2018
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.021
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
¿Y en qué línea sale el error?
¿Has seguido el código con el depurador?
Responder Con Cita
  #8  
Antiguo 11-06-2018
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.233
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
La mayoría de las veces, este error suele dar cuando intentamos convertir un String a Float, sin tener en cuenta los separadores de miles y de decimales. O cuando estamos usando una diferente a la del sistema.

Deberías ver si el número que estás convirtiendo tiene alguno de estos separadores.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
is not a valid floating point angelratza Varios 2 21-06-2017 00:00:22
''not a valid floating point value Ian_Martinez Varios 7 20-02-2015 17:32:25
is not a valid floating point value donpedro Varios 6 22-11-2012 17:58:08
is not a valid floating point value ale_metall SQL 5 24-05-2008 17:44:01
1,253 is not valid floating point value soyhugo Varios 7 14-02-2004 06:40:53


La franja horaria es GMT +2. Ahora son las 03:37:52.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi