S
sungods
Unregistered / Unconfirmed
GUEST, unregistred user!
写了一个可以针对序号自增的函数.但是输入是9,99,999...的情况都会报错.......
函数说明:
function IncAPPNo( AppNo : string):string;stdcall;
var i : integer;
str : array[0..16] of char;
tmp : integer;
Ostr: string;
flag: integer;
sl : integer;
s : string;
begin
for I := 0 to 16 do
begin
str:='0';
end;
flag := 1;
if (length(Appno)>16) then
begin
showmessage('请控制交易序号在16位以内');
exit;
end;
strcopy(str,pchar(appno));
//字符长度
sl:=length(appno);
form1.Caption:='字符长度:'+inttostr(sl);
while (flag=1) do
begin
s := str[sl-1];
tmp := strtoint(s)+1;
s := inttostr(tmp);
showmessage(s[1]);
if (tmp = 10) then
begin
str[sl-1]:='0';
flag:=1;
end
else
begin
str[sl-1]:=s[1];
flag:=0;
end;
dec(sl);
end;
result := str;
end;
函数说明:
function IncAPPNo( AppNo : string):string;stdcall;
var i : integer;
str : array[0..16] of char;
tmp : integer;
Ostr: string;
flag: integer;
sl : integer;
s : string;
begin
for I := 0 to 16 do
begin
str:='0';
end;
flag := 1;
if (length(Appno)>16) then
begin
showmessage('请控制交易序号在16位以内');
exit;
end;
strcopy(str,pchar(appno));
//字符长度
sl:=length(appno);
form1.Caption:='字符长度:'+inttostr(sl);
while (flag=1) do
begin
s := str[sl-1];
tmp := strtoint(s)+1;
s := inttostr(tmp);
showmessage(s[1]);
if (tmp = 10) then
begin
str[sl-1]:='0';
flag:=1;
end
else
begin
str[sl-1]:=s[1];
flag:=0;
end;
dec(sl);
end;
result := str;
end;