"物料编码"为字符型(A100000),我想结取它的后六位数,然后再转为数值型的,用来自动增加编码数字.但不知该用那个结取涵数?
例:AX:=strtoint(结取函数(query3.fieldbyname('物料编码').Asstring));是不是可以这样?

解决方案 »

  1.   

    AX:=strtotint(right(query3.fieldbyname('物料编码').Asstring,6));
      

  2.   

    上边写错了AX:=strtotint(rightStr(query3.fieldbyname('物料编码').Asstring,6));还要引用unit:StrUtils最好用 trystrtoint再判断一下是不是能够转为INT,
      

  3.   

    不行哟!
    var
    maxno,tmp:integer;
    beginwith query3 do
    begin
    open;
    first;
    maxno:=strtotint(rightStr(query3.fieldbyname('材料类别').Asstring),6);提示这行不对呀?
    while not eof do
    begin
    tmp:=strtotint(rightstr(query3.fieldbyname('材料类别').Asstring),6);
    if maxno<tmp then maxno:=tmp;
    next;
    end;
    close;
    end;
    combobox3.text:=inttostr(maxno+1);
    end;
      

  4.   

    你寫的不對,括號!
    maxno:=strtotint(rightStr(query3.fieldbyname('材料类别').Asstring,6));
      

  5.   

    Query.sql.text:='select right([物料编码],6) from table1';
      

  6.   

    var
    maxno,tmp:integer;
    beginwith query1 do
    begin
    open;
    first;
    maxno:=strtotint(rightStr(query3.fieldbyname('材料类别').Asstring,6));
    while not eof do
    begin
    TEM:=strtotint(rightStr(query3.fieldbyname('材料类别').Asstring,6));
    if maxno<tmp then maxno:=tmp;
    next;
    end;
    close;
    end;
    combobox3.text:=inttostr(maxno+1);
    end;
    也不行呀
      

  7.   

    真服了几位了..
    好像很简单的啊,使用copy就应该可以了吧.."物料编码"为字符型(A100000),我想结取它的后六位数,然后再转为数值型的,用来自动增加编码数字.但不知该用那个结取涵数?
    例:AX:=strtoint(结取函数(query3.fieldbyname('物料编码').Asstring));是不是可以这样?
    ......
    temp:=copy(trim(query3.fieldbyname('物料编码').Asstring),3,6);
    strtoint(temp)+1;
    ......
      

  8.   

    easy
    right(query3.fieldbyname('物料编码').Asstring,6)就可以了
      

  9.   

    LeftStr(str,n):从左向右,截取n个字符 
    RightStr(str,n):从右向左,截取n个字符 
    Copy(str,index,n):从任意位置,截取n个字符楼主自己看着办......
      

  10.   

    AX:=StrToIntDef(Copy(Trim(query3.fieldbyname('物料编码').Asstring),Length(Trim(query3.fieldbyname('物料编码').Asstring))-5, 6),0);