IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++Builder Discussion :

EConvert Error


Sujet :

C++Builder

  1. #1
    Membre éclairé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2008
    Messages
    241
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2008
    Messages : 241
    Par défaut EConvert Error
    Bonjour tous le monde j’ai écrit le code suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    //---------------------------------------------------------------------------
     
    #include <vcl.h>
    #pragma hdrstop
     
    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
     
    void __fastcall TForm1::Edit1Change(TObject *Sender)
    {
    if(Edit1->Text==' ')
    {
    StringGrid1->ColCount=5;
    StringGrid1->RowCount=5;
    StringGrid2->ColCount=5;
    }
    else
    {
    StringGrid1->ColCount=StrToInt(Edit1->Text);
    StringGrid1->RowCount=StrToInt(Edit1->Text);
    StringGrid2->ColCount=StrToInt(Edit1->Text);
    }
    }
    //---------------------------------------------------------------------------
     
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    int f=1;
    int t=1;
    int a=1;
    int k=1;
    int i,j,min=10000;
    bool bol;
     
    i=StrToInt(Edit2->Text);
    while(i<=StrToInt(Edit1->Text))
    if(a<=StrToInt(Edit1->Text)+1)
    {
    t++;
    for(j=1;j<=StrToInt(Edit1->Text);j++)
    {k++;
    if(StrToInt(StringGrid1->Cells[j][i])<min)
    while(k<=StrToInt(Edit1->Text))
    {
    if(StrToInt(StringGrid2->Cells[k][1])==j)
    break;
    else
    k++; bol=true;
    if(k==StrToInt(Edit1->Text) && bol==true)
    {min=StrToInt(StringGrid1->Cells[j][i]);
    f=j;
    }
    }
    }
    StringGrid2->Cells[t][0]=IntToStr(f);
        StringGrid2->Cells[t-1][1]=IntToStr(min);         
       StringGrid2->Cells[StrToInt(Edit1->Text)][1]=StringGrid1->Cells[StrToInt(Edit2->Text)][StrToInt(StringGrid2->Cells[StrToInt(Edit1->Text)][0])];
     
    a++;
     
    }
     
     
     
    }
    //---------------------------------------------------------------------------
    puits pendant le traitement je reçois ce message

    Project project1.exe raised exception class EConvert Error withe message "is not valid intger value" alors que toutes données son entier.

    quelqu’un peut m’aidé.
    Merci

  2. #2
    Expert confirmé

    Avatar de pottiez
    Homme Profil pro
    Développeur C++
    Inscrit en
    Novembre 2005
    Messages
    7 152
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur C++
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2005
    Messages : 7 152
    Par défaut
    Une seul chose pourra t'aider dans ce cas, c'est le debugage, effectivement ca n'as pas l'air d'être une erreur de code, a condition bien sur que t'es TEdit soit remplit de chiffre ainsi que les cellule de ton StringGrid

  3. #3
    say
    say est déconnecté
    Membre Expert
    Avatar de say
    Profil pro
    Inscrit en
    Août 2002
    Messages
    1 176
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France

    Informations forums :
    Inscription : Août 2002
    Messages : 1 176
    Par défaut
    les données sont peut-tre toutes des entiers...mais ça a l'air de le géner quand même.
    un peu de débug, de points d'arrêt devrait te permettre d'identifier la ligne incrimée. une fois la ligne identifiée, tu pourras revenir vers nous.

    Bon courage

  4. #4
    Membre Expert
    Avatar de Crayon
    Inscrit en
    Avril 2005
    Messages
    1 811
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 811
    Par défaut
    La meilleure pratique est l'utilisation de try/catch pour les conversions.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    try
    {
        i = StrToInt("BOB");
    }
    catch(EConvertError &E)
    {
        i = 0;
    }
    Si tu veux, tu mets un message d'erreur dans ton catch ou tu mets une valeur par défaut à ta variable.

Discussions similaires

  1. ERROR: pg_atoi: zero-length string
    Par steelspirit92 dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 23/08/2003, 22h29
  2. [SQL Server] Error converting data type varchar...
    Par Sir Tengu dans le forum MS SQL Server
    Réponses: 9
    Dernier message: 13/06/2003, 10h46
  3. [Kylix] Kylix c++ error
    Par pacpac dans le forum EDI
    Réponses: 2
    Dernier message: 10/06/2003, 16h27
  4. [CR] Print Engine error text
    Par afaraji dans le forum SAP Crystal Reports
    Réponses: 1
    Dernier message: 03/09/2002, 15h44
  5. [Kylix] Runtime error 230 avec INDY
    Par Anonymous dans le forum EDI
    Réponses: 2
    Dernier message: 23/03/2002, 11h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo