代码如下
var
Form1: TForm1;
Maxbit: integer;
Num: array of char;
procedure TForm1.Button1Click(Sender: TObject)
//程序开始
var
i: integer;
begin
maxbit:=strtoint(MaskEdit1.Text);
setlength(num,maxbit);
for i:=0 to maxbit-1 do
begin
num:='0';
end;
Timer1.Enabled:=not Timer1.Enabled;
end;
procedure TForm1.DoUp
//进行进位
var
i,j :integer;
begin
for i:=maxbit-1 downto 0 do
begin
if (num=':') then
num:='A';
if (num='G') then
begin
num:='0';
num[i-1]:=char(ord(num[i-1])+1);
end;
end;
end;
function TForm1.IsEnd: boolean
//判断是否全为F
var
i:integer;
begin
result:=true;
for i := 0 to maxbit-1 do
begin
if (num<>'F') then
begin
Result:=False;
exit;
end;
end;
end;
procedure TForm1.ShowNum
//显示数字
var
i: integer;
s: string;
begin
s:='';
for i:=0 to maxbit-1 do
begin
s:=s+num;
end;
Label2.Caption:=s;
Label2.Repaint;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
num[maxbit-1]:=Char(ord(num[maxbit-1])+1);
DoUp;
ShowNum;
if IsEnd then
Timer1.Enabled:=false;
end;