2、 var s : string; i : integer; begin s := ADOQuery1.FieldByName('YourField').AsString; try i := StrToInt(s); except { 异常报告 } end; Inc(i); With ADOQuery1 do begin open; Locate(..); Edit; FieldByName('YourField').AsString := IntToStr(i); try Post; Except {异常报告} end; end; end;
{ 让S成为Count位数的字符串,不够的则用SpecStr来填充 } { HTFlag 0: 在头部填充 1: 在尾部填充} function FullString(Count: integer; S : string; SpecStr: char; HTFlag: integer): string; var i: integer; strTmp : string; begin if Length(S) >= Count then Result := S else begin strTmp := ''; for i := 1 to Count - Length(S) do strTmp := strTmp + SpecStr; case HTFlag of 0 : Result := strTmp + S; 1 : Result := S + strTmp; end; end; end;
Edit1.Text := ADOQuery1.FieldByName('TableField').AsString;
edit.text:=dataset.FieldByName('你的字段').asstring;
var
s : string;
i : integer;
begin
s := ADOQuery1.FieldByName('YourField').AsString;
try
i := StrToInt(s);
except
{ 异常报告 }
end;
Inc(i);
With ADOQuery1 do begin
open;
Locate(..);
Edit;
FieldByName('YourField').AsString := IntToStr(i);
try
Post;
Except
{异常报告}
end;
end;
end;
select right('000000'+replace(str('000001'+1),' ',''),6)
其中'000001'你换成你取出来的字段值
第一个' '这里有一个空格
{ HTFlag 0: 在头部填充 1: 在尾部填充}
function FullString(Count: integer; S : string; SpecStr: char;
HTFlag: integer): string;
var
i: integer;
strTmp : string;
begin
if Length(S) >= Count then
Result := S
else begin
strTmp := '';
for i := 1 to Count - Length(S) do
strTmp := strTmp + SpecStr;
case HTFlag of
0 : Result := strTmp + S;
1 : Result := S + strTmp;
end;
end;
end;
将原来的值'00000X'变成'00000Y' 请中Y=X+1
i:integer;
i:=strtoint(table1.fields[0].asstring);
format('%0.6',[i]);