请问定义一个数值为001,002,003..100的语句怎么写?(100)

剑魂

Unregistered / Unconfirmed
GUEST, unregistred user!
以前写过,忘记了[:(][:(][:(]
 
D

de410

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject);
private { Private declarations } public { Public declarations } end;
var Form1: TForm1;implementation{$R *.dfm}Function fmt(n:integer):string;var j:integer;
begin
j:=length(inttostr(n));
case j of 1:result:='00'+inttostr(n);
2:result:='0'+inttostr(n);
3:result:=inttostr(n);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);var i:integer;
begin
for i:=1 to 100do
begin
showmessage(fmt(i));
end;
end;
end.
 
P

Passion

Unregistered / Unconfirmed
GUEST, unregistred user!
type THundred = 1..100;var a: THundred;a就只能是1到100了。
 
L

liuls

Unregistered / Unconfirmed
GUEST, unregistred user!
定义子界类型的话,如 Passion 所说;输出的话可用 Format()var I: Integer;
begin
for I := 1 to 100do
mmo1.lines.add(Format('%.3d', ));
end;
 
W

wind_2005

Unregistered / Unconfirmed
GUEST, unregistred user!
你好像说的不是很清楚,一个数值能定义为多个值呢?而且是001,002,003.....,001只能是字符串而不能是数值。所以你描述清楚后大家才好帮你。[:)]
 
Top Bottom