全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1419
推到 Plurk!
推到 Facebook!

出現'''is not a volid integer value'錯誤

缺席
iii0628
一般會員


發表:50
回覆:46
積分:19
註冊:2005-04-04

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-10-18 14:13:03 IP:220.130.xxx.xxx 未訂閱
請問我現在的程式是第一段的話執行上沒有錯誤,為何我將StringGrid1的ROW加大內容之後,就會出現錯誤(ROW只要超過180就會出錯)。可以幫我看看嗎??? 我已經找好久都無法解刁....謝謝 第一段
 
StringGrid1的RowCout=37
StringGrid1的ColCout=39
 
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
    int i, j;      //設定Row Header 以及Column Header的數字
  for (i = 0 ; i <= 38 ; i  )
  {
      StringGrid1->Cells[i][0] = IntToStr(i);
      StringGrid2->Cells[i][0] = IntToStr(i);
  }       for (j = 0 ; j <= 36 ; j  )
  {
      StringGrid2->Cells[0][j] = IntToStr(j);
  }      for (j = 0 ; j <= 72 ; j  )
  {
      StringGrid1->Cells[0][j] = IntToStr(j);
  }        for(int col=1;col<=38;col  ){
      for(int row=1;row<=72;row  ){
        StringGrid1->Cells[col][row] =3;
        StringGrid2->Cells[col][row] =0;
        }            }    }
//---------------------------------------------------------------------------    void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
int row=0, col=0;  // 供處理行列資料的迴圈使用
int rowstep =0;
int restartRow=0;  // 每次重新處理的第一行 (row) 編號
int processRows = 0;  // 存放處理行數 (rows) 的累加數字
int tmpNum;  // 暫存用之變數    rowstep =(StringGrid1->RowCount-1) / 36; // 將總行數 (rows) 除以 36 做為迴圈的計算基底    for (restartRow=1; restartRow<=36; restartRow  ) {  // 處理 36 次        for (row=restartRow; row<=(restartRow 35)*(rowstep-1) 1; row =36) {  // 每次隔 36 行 (rows)
      //  processRows  ;  // 累加處理行數 (rows)
       // if (processRows > (StringGrid1->RowCount-1)) {  // 若超過處理範圍就跳出迴圈
       //     break;
      //  }            for (col=1; col<=38; col  ) {  // 逐欄 (column) 比對
            if (StrToInt(StringGrid1->Cells[col][row]) > 1) {  // 若比對欄位的數字大於 1
                tmpNum = StrToInt(StringGrid2->Cells[col][restartRow]) 1;  // 取得 StringGrid2 對應欄位的數字並加 1
                StringGrid2->Cells[col][restartRow] = tmpNum;  // 回存累加數字
            }
        }
    }
}    }
第二段 StringGrid1的RowCout=181 StringGrid1的ColCout=39 __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { int i, j; //設定Row Header 以及Column Header的數字 for (i = 0 ; i <= 38 ; i ) { StringGrid1->Cells[i][0] = IntToStr(i); StringGrid2->Cells[i][0] = IntToStr(i); } for (j = 0 ; j <= 36 ; j ) { StringGrid2->Cells[0][j] = IntToStr(j); } for (j = 0 ; j <= 180 ; j ) { StringGrid1->Cells[0][j] = IntToStr(j); } for(int col=1;col<=38;col ){ for(int row=1;row<=180;row ){ StringGrid1->Cells[col][row] =3; StringGrid2->Cells[col][row] =0; } } } //--------------------------------------------------------------------------- void __fastcall TForm1::BitBtn1Click(TObject *Sender) { int row=0, col=0; // 供處理行列資料的迴圈使用 int rowstep =0; int restartRow=0; // 每次重新處理的第一行 (row) 編號 int processRows = 0; // 存放處理行數 (rows) 的累加數字 int tmpNum; // 暫存用之變數 rowstep =(StringGrid1->RowCount-1) / 36; // 將總行數 (rows) 除以 36 做為迴圈的計算基底 for (restartRow=1; restartRow<=36; restartRow ) { // 處理 36 次 for (row=restartRow; row<=(restartRow 35)*(rowstep-1) 1; row =36) { // 每次隔 36 行 (rows) // processRows ; // 累加處理行數 (rows) // if (processRows > (StringGrid1->RowCount-1)) { // 若超過處理範圍就跳出迴圈 // break; // } for (col=1; col<=38; col ) { // 逐欄 (column) 比對 if (StrToInt(StringGrid1->Cells[col][row]) > 1) { // 若比對欄位的數字大於 1 tmpNum = StrToInt(StringGrid2->Cells[col][restartRow]) 1; // 取得 StringGrid2 對應欄位的數字並加 1 StringGrid2->Cells[col][restartRow] = tmpNum; // 回存累加數字 } } } } } [/code]
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-10-18 14:53:12 IP:203.69.xxx.xxx 未訂閱
您好:    錯誤訊息表示你在StrToInt()時出現非法的內容導致無法轉成整數 下斷點然後用F7 F8 Trace程式碼就可以找到哪邊出現錯誤了    順心
iii0628
一般會員


發表:50
回覆:46
積分:19
註冊:2005-04-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-10-18 15:17:17 IP:220.130.xxx.xxx 未訂閱
taishyang:你好,謝謝你的幫忙。我已經找到問題了,我是將if判斷式中StrToInt拿掉就好了,但是StringGrid裡的內容不是應該要先轉成數字再做判斷會比較安全嗎???結果我加入之後反而會出錯
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-10-18 16:11:00 IP:203.69.xxx.xxx 未訂閱
您好: 程式的邏輯只有您自己最清楚囉,建議您再檢查看看
系統時間:2024-05-10 5:51:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!