SoloCodigo
Programación General => C/C++ => C++ Builder => Mensaje iniciado por: janus.ast en Viernes 21 de Julio de 2006, 18:05
-
Por que me sale este erro dentro de mi programa EconvertError with Message cualquier numero con decimales is not avalid integer value ayuda por favor
-
Puedes poner tu codigo para checarlo o darnos mas pistas para poder ayudarte...
-
este es el codigo el error lo marca donde calcula el label 9 y label 10
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "main.h"
//The ZiC
// 2002
// Ejemplo de como carga la DLL NumToTxt.dll
// zic_98@hotmail.com
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
i=0;j=0,k=0;
Label1->Caption=0;
Label6->Caption=0;
Tabla2->Cells[0][0]=0;
Tabla2->Cells[1][0]=0;
}
//-----------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
j=j+1;
for(i=0;i<j;i++) {
if(Tabla2->Cells[0]==0 && Tabla2->Cells[1]==0) {
ShowMessage("Introduce Datos Correctos");}
else{
Label1->Caption=FormatFloat("#.#####",Label1->Caption.ToDouble()+(Tabla2->Cells[0].ToDouble()*Tabla2->Cells[1].ToDouble()));
Tabla2->Cells[2]=FormatFloat("#.#####",Tabla2->Cells[0].ToDouble()*Tabla2->Cells[1].ToDouble());
} }
{
Label9->Caption=FormatFloat("#.#####",Label1->Caption.ToDouble()* (0.15));
Label10->Caption=FormatFloat("#.#####",Label1->Caption.ToDouble()+Label9->Caption.ToDouble());
Edit1->Text=Label10->Caption;
typedef AnsiString(*funcion)(double);
funcion Num2Txt;
//carga de la dll dinamicamente
HINSTANCE dllinstance=LoadLibrary("NumToTxt.dll");
if(dllinstance==NULL) ShowMessage("Error al cargar la dll");
//busqueda de la direccion de la funcion
Num2Txt=(funcion)GetProcAddress(dllinstance,"_NumToTxt");
if(Num2Txt==NULL)
ShowMessage("Error en la funcion");
else
Edit2->Text=Num2Txt(StrToInt64(Edit1->Text));
FreeLibrary("NumToTxt.dll");
TStringList *Ar = new TStringList();
Ar->Clear();
Ar->Add(Edit17->Text);
Ar->Add(Edit16->Text);
Ar->Add(Edit18->Text + Edit19->Text + Edit20->Text +" "+ Edit21->Text+ " "+ Edit22->Text);
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
for(i=0;i<j;i++){
Ar->Add(" " + Tabla2->Cells[0]+" "+ Tabla1->Cells[0] +" "+ Tabla2->Cells[1]+" " + Tabla2->Cells[2]);
}
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" "+ Label1->Caption);
Ar->Add(" "+ Label9->Caption);
Ar->Add(" "+ Label10->Caption);
Ar->Add(" " + Edit2->Text);
Ar->SaveToFile("archivo.txt");
delete Ar;
}
Label6->Caption=Label1->Caption;
Label1->Caption=0;
j=j-1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DBGrid1CellClick(TColumn *Column)
{
Edit16->Text=(tbClientes->FieldByName("RFC")->AsString);
Edit17->Text=(tbClientes->FieldByName("NOMBRE O RAZON SOCIAL")->AsString);
Edit18->Text=(tbClientes->FieldByName("CALLE")->AsString);
Edit19->Text=(tbClientes->FieldByName("COLONIA")->AsString);
Edit20->Text=(tbClientes->FieldByName("CODIGO POSTAL")->AsString);
Edit21->Text=(tbClientes->FieldByName("CUIDAD")->AsString);
Edit22->Text=(tbClientes->FieldByName("ESTADO")->AsString);
Button5->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
if( Tabla2->Cells[0]==0 && Tabla2->Cells[1]==0) {
Tabla2->Cells[0][j]=0;
Tabla2->Cells[1][j]=0;
}
if( RadioButton2->Checked==true)
{
j++;
Tabla1->RowCount=j+1;
Tabla2->RowCount=j+1;
Button1->Enabled=true;
Tabla2->Cells[0][j]=0;
Tabla2->Cells[1][j]=0;
RadioButton2->Checked=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
j=j+1;
for(i=0;i<j;i++) {
if(Tabla2->Cells[0]==0 && Tabla2->Cells[1]==0) {
ShowMessage("Introduce Datos");}
else{
Label1->Caption=Label1->Caption.ToDouble()+(Tabla2->Cells[0].ToDouble()*Tabla2->Cells[1].ToDouble());
Tabla2->Cells[2]=Tabla2->Cells[0].ToDouble()*Tabla2->Cells[1].ToDouble();
} }
{
TStringList *Ar = new TStringList();
Ar->Clear();
Ar->Add(Edit17->Text);
Ar->Add(Edit16->Text);
Ar->Add(Edit18->Text + Edit19->Text + Edit20->Text +" "+ Edit21->Text+ " "+ Edit22->Text);
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
for(i=0;i<j;i++){
Ar->Add(" " + Tabla2->Cells[0]+" "+ Tabla1->Cells[0] +" "+ Tabla2->Cells[1]+" " + Tabla2->Cells[2]);
}
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" ");
Ar->Add(" " + Label1->Caption);
Ar->SaveToFile("archivo.txt");
delete Ar;
}
Label6->Caption=Label1->Caption;
Label1->Caption=0;
j=j-1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Tabla2GetEditMask(TObject *Sender, int ACol,
int ARow, AnsiString &Value)
{
if( Tabla2->Col == 0 )
Value = "00000000";
if( Tabla2->Col == 1 )
Value = "00000000";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Tabla2DrawCell(TObject *Sender, int ACol, int ARow,
TRect &Rect, TGridDrawState State)
{
{
{
if( ((TStringGrid *)Sender)->Focused( ) != true ){
if( ((TStringGrid *)Sender)->Row == ARow && ((TStringGrid *)Sender)->Col == ACol ){
((TStringGrid *)Sender)->Canvas->Brush->Color = ((TStringGrid *)Sender)->Color;
((TStringGrid *)Sender)->Canvas->FillRect( Rect );
((TStringGrid *)Sender)->Canvas->Font->Color = ((TStringGrid *)Sender)->Font->Color;
((TStringGrid *)Sender)->Canvas->TextOut( Rect.Left + 2, Rect.Top + 2, ((TStringGrid *)Sender)->Cells[ACol][ARow] );
}
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Tabla2KeyPress(TObject *Sender, char &Key)
{
{
{
if((Key < '0' || Key > '9')&& Key != *"\b")
Key=0;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Tabla1GetEditMask(TObject *Sender, int ACol,
int ARow, AnsiString &Value)
{
{
if( Tabla1->Col == 0 )
Value = "a a a a a a a a a a a a a a a a a a a a ";
}
}
//---------------------------------------------------------------------------
-
Parece que no hay error en el codigo, pero una vez me paso lo mismo, todo parecia estar bien codificado, y en la ejecucion aparecia un error con los numero flotantes, no recuerdo bien el mensaje de error. Pero el problema era que no podia convertir un AnsiString a Flotante por la configuracion regional y de idioma de windows.
Lo que paso era que se intentaba introducir por un edit un numero foltante, por ejemplo:
325.5
pero al querer usar la funcion StrToFloat marcaba error. Lo que paso era que en la configuracion regional, estaba configurado como Español de españa, y la notacion para los numeros cambia pues es coma flotante. Entonces un numero flotante era 325,5 con ',' no con '.'
Y se soluciono cambiando a Español de Mexico, en la que se usa punto flotante
Tal vez y ese no sea tu problema, pero eso fue lo que me paso, no se si me explique bien.