var
i:=integer;
str:string;
begin
i:=0if table1.recordcount<>0 then
   table1.first;
   while not eof do
    begin
      str:=copy(fields[0].asstring,1,5);
       if edit1.text=str then
        inc(i);
     end;
end;
i是指其中有这个字符串的数目,,,,,每次执行都死机....不知是为什么/////////(我着是平印象写的..编译已经通过了..如果少标点什么的,旧不要说了

解决方案 »

  1.   

    while not eof do
        begin
          str:=copy(fields[0].asstring,1,5);
           if edit1.text=str then
            inc(i);
          next;//移动下一条记录
         end;
      

  2.   

    忘了写了。
    我的程序里是有的 。
    我现在就是说为什么一执行就死机。copy函数如果找不到。fields[0].asstring的值,是不是这个原因呀
      

  3.   


    table1.first;
       while not table1.eof do
        begin
          str:=copy(table1.fields[0].asstring,1,5);
           if edit1.text=str then
            inc(i);
            Table1.Next
         end;
      

  4.   

    if table1.recordcount<>0 then
    table1.first;
    while not table1.eof do
    begin
      str:=copy(fields[0].asstring,1,5);
      if edit1.text=str then
      inc(i);
      table1.next;
    end;
    end;
      

  5.   

    while not table1.eof do
    begin
      if Fields[0].isnull then //判断是否为空为空时就会出现你说的错误.
          str:='' 
       else 
          str:=copy(fields[0].asstring,1,5);
      if edit1.text=str then
      inc(i);
      table1.next;
    end;