Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 20-01-2016
Avatar de AzidRain
[AzidRain] AzidRain is offline
Miembro Premium
 
Registrado: sep 2005
Ubicación: Córdoba, Veracruz, México
Posts: 2.914
Poder: 23
AzidRain Va camino a la fama
Asegúrate de iniciar absolutamente todas las variables que intervienen antes de hacer cualquier cosa. El problema que tienes es que alguna no esta inicializada y recordemos que cuando eso pasa es imposible saber que valor le dará el sistema al momento de ejecutarse, normalmente es un valor pseudoaleatorio y en una de esas te toca un cero y eso te produce el error. De todos modos si no pones la totalidad del código lo demás es especular.
__________________
AKA "El animalito" ||Cordobés a mucha honra||
Responder Con Cita
  #2  
Antiguo 20-01-2016
Camilo Camilo is offline
Miembro
 
Registrado: jun 2007
Posts: 149
Poder: 20
Camilo Va por buen camino
Gracias amigo AzidRain por el tiempo que te tomas para ayudarme.
Con este codigo Llamo algunas funciones financieras que dan error en algunas maquinas. Se activa cuando rayamos un codigo de barras.

Código Delphi [-]
procedure TFVenta.Edit1Exit(Sender: TObject);
begin
if Trim(Edit1.Text) <> '' then
  // Esta lleno
  begin
  Actualiza;
  SumaCantidad;
  Impuesto;
  SumarImp;
  Subtotal;
  end
else
  // No esta lleno
end;

Las funciones son las siguientes:

Código Delphi [-]
Procedure TFVenta.Actualiza;
begin
with DataModule1.IBQInventarios do begin
  if active then Close; //Agregué aquí
  sql.Clear; // y aquí
  SQL.Add('Select * From INVENTARIO');
  SQL.Add('Where Codigo_Producto = '+QuotedStr(Edit1.Text));
  Open;
  if not IsEmpty then begin
StringGrid1.Row := StringGrid1.Rowcount - 1;
StringGrid1.Cells[0, StringGrid1.Row]:= fieldbyname('CODIGO_PRODUCTO').AsString;
StringGrid1.Cells[1, StringGrid1.Row]:= fieldbyname('NOMBRE_PRODUCTO').AsString;
StringGrid1.Cells[2, StringGrid1.Row]:= fieldbyname('REFERENCIA_PRODUCTO').AsString;
StringGrid1.Cells[3, StringGrid1.Row]:= fieldbyname('CATEGORIA').AsString;
StringGrid1.Cells[4, StringGrid1.Row]:= '1';   //CANTIDAD
StringGrid1.Cells[5, StringGrid1.Row]:= fieldbyname('PRECIO').AsString;

  Edit1.Clear;
  Edit1.SetFocus;
  StringGrid1.RowCount := StringGrid1.RowCount + 1;
  Sumar;
  Puntos;

  end else begin
  ShowMessage('PRODUCTO NO EXISTE EN INVENTARIO');
  Edit1.Clear;

  Edit1.SetFocus;
  end;
end;
end;


Código Delphi [-]
Procedure TFVenta.SumaCantidad;
var
k, Suma: integer;
a, c, d: Extended;
begin
  d:= 0;
  a := StrToInt(StringGrid1.Cells[5, StringGrid1.Row]); // Precio
  c := StrToInt(Edit8.Text); //Cantidad
  d:=  (a*c); // Precio x Cantidad

StringGrid1.Cells[4, StringGrid1.Row]:=  Edit8.Text;  //CANTIDAD
StringGrid1.Cells[6, StringGrid1.Row]:=  FormatFloat('$ #0,.00',d);
StringGrid1.Cells[8, StringGrid1.Row]:= FloatToStr(d);

Suma := 0;
  StringGrid1.Cells[7, StringGrid1.Row]:= StringGrid1.Cells[1, StringGrid1.Row];
  for k := 0 to StringGrid1.RowCount - 1 do
    if k <= StringGrid1.RowCount - 1 then
      Suma := Suma + StrToIntdef(StringGrid1.Cells[8, k + 1], 0);
      Edit7.Text:=  FormatFloat('$ #0,.00', Suma);
      Edit5.Text:=  IntToStr(Suma);
end;

Código Delphi [-]
Procedure TFVenta.Impuesto;
begin
DataModule1.IBQInvFact.Close;
DataModule1.IBQInvFact.ParamByName('Codigo').AsString := StringGrid1.Cells[0, StringGrid1.Row];
DataModule1.IBQInvFact.Open;
end;

Código Delphi [-]
Procedure TFVenta.SumarImp;
var
 a,b,c,d,e,f,z: Extended;
 j, Suma: integer;
begin
  z:= 0;
  a:= StrToInt(DbEdit2.Text);   //Iva
  b:= StrToInt(DbEdit3.Text);   //Otro_Imp
  c:= 1+((a+b)/100); //   Suma Impuestos
  d:= StrToInt(StringGrid1.Cells[5, StringGrid1.Row])* StrToInt(StringGrid1.Cells[4, StringGrid1.Row]); // Precio
  f:= d/c;
  z:= d-f;

  if z > 0 then

StringGrid1.Cells[7, StringGrid1.Row]:=  FormatFloat('#####', z)
else
  StringGrid1.Cells[7, StringGrid1.Row]:=  ('0');
Suma := 0;
  StringGrid1.Cells[7, StringGrid1.Row];
  for j := 0 to StringGrid1.RowCount - 1 do
    if j <= StringGrid1.RowCount - 1 then
      Suma := Suma + StrToIntdef(StringGrid1.Cells[7, j + 1], 0);
      Edit2.Text:=  FormatFloat('$ #0,.00', Suma);
      Edit14.Text:=  IntToStr(Suma);
end;

Código Delphi [-]
Procedure  TFVenta.Subtotal;
var
Precio, Impuesto, Resultado: Extended;
begin
Precio:= StrToInt(Edit5.Text);
Impuesto:= StrToInt(Edit14.Text);
Resultado:= ((Precio - Impuesto));
Edit4.text:= FormatFloat('$ #0,.00', Resultado);
Edit16.Text:=  FloatToStr(Resultado);
end;

Lo de las variables me suena muy logico. solo quiero si no es molestia que revises los codigos para que me ratifiques o como tu mismo dices, no especular.
Gracias amigo y a todos los que tengan a bien opinar y aportar sobre el tema.
Responder Con Cita
  #3  
Antiguo 20-01-2016
Avatar de Al González
[Al González] Al González is offline
In .pas since 1991
 
Registrado: may 2003
Posts: 5.610
Poder: 32
Al González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en bruto
Recuerda que Delphi tiene un muy buen depurador. ¿En qué línea te marca la excepción?
Responder Con Cita
  #4  
Antiguo 20-01-2016
Camilo Camilo is offline
Miembro
 
Registrado: jun 2007
Posts: 149
Poder: 20
Camilo Va por buen camino
Hola Al. No se cual linea es la del error; resulta que en la maquina donde tengo la fuente (Osea la mia) no da error por ningun lado, entonces voy a otras maquinas y ahi si bota el error. como alla ejecuto el programa no he tenido la oportunidad de ver ese detalle.
Lo que he intentado es inhabilitar partes de codigo donde creo puede estar el error pero igual me sigue saliendo y no he podido ver en donde esta.
En sintesis la depuracion en mimaquina no marca nada pero la ejecucion en algunas maquinas marca el error. en otras maquinas la ejecucion tampoco marca error.
Gracias
Responder Con Cita
  #5  
Antiguo 20-01-2016
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.669
Poder: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
El error puede ser ocasionado por artículos que tienen precio cero. Y seguramente se produce aquí.
Código Delphi [-]
  z:= 0;
  a:= StrToInt(DbEdit2.Text);   //Iva
  b:= StrToInt(DbEdit3.Text);   //Otro_Imp
  c:= 1+((a+b)/100); //   Suma Impuestos
  d:= StrToInt(StringGrid1.Cells[5, StringGrid1.Row])* StrToInt(StringGrid1.Cells[4, StringGrid1.Row]); // Precio
  f:= d/c;
  z:= d-f;
Quiero decir que aparentemente el problema es según qué artículo se escoge, y no por la máquina donde se hace la prueba.
Responder Con Cita
  #6  
Antiguo 20-01-2016
Camilo Camilo is offline
Miembro
 
Registrado: jun 2007
Posts: 149
Poder: 20
Camilo Va por buen camino
Casimiro voy a revisar con muchos productos y te cuento. Gracias por tu interés.
Responder Con Cita
  #7  
Antiguo 20-01-2016
Avatar de AgustinOrtu
[AgustinOrtu] AgustinOrtu is offline
Miembro Premium
NULL
 
Registrado: ago 2013
Ubicación: Argentina
Posts: 1.858
Poder: 17
AgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en bruto
Yo creo que la excepción es muy clara:

Se produce cuando se divide un número por 0

La solución es revisar en el código donde se divida, sobre todo en donde los valores pueden venir de parte del usuario

Tenés dos alternativas, no permitir que se ingrese el 0 que va a terminar como divisor, o bien validar siempre el divisor y en lugar de dividir, cambiar el resultado por otro

Saludos
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
"Not a valid floating point value" david.rguez Varios 2 12-12-2007 13:42:57
""" is not a valid floating point value con edit Petolansa Varios 6 11-12-2007 00:07:13
"floating point overflow" en campocalculado ANXO Conexión con bases de datos 0 22-01-2006 16:59:58
deadlock en unas maquinas pero no en otras ??? DobleSiete Conexión con bases de datos 6 01-06-2005 14:12:58
Unas preguntas? Waldo Conexión con bases de datos 2 01-11-2003 06:45:50


La franja horaria es GMT +2. Ahora son las 20:49:11.


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