求delphi自动生成编号代码
比如说医院的门诊编号,每次自动加一。或者不重复的随机数也可以。
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
curdate:string;
begin
adotable1.open;
for i:=1 to adotable1.recordcount do
begin
adotable1.edit;
curdate:=FormatDatetime('yyyy年mm月dd日',now);
adotable1.fieldbyname('id').value:=curdate+char(32)+'第'+inttostr(i)+'号';
next;
end;
end;