先定义一个函数:
private function weekday(WDays:Integer):string;
看实现部分的代码:
function TForm1.weekday(WDays: Integer): string; type Tweek=(sunday,monday,tuesday,wednesday,thursday,friday,saturday); var Days,NextDay:Tweek; begin case WDays of 0:Days:=sunday; 1:Days:=monday; 2:Days:=tuesday; 3:Days:=wednesday; 4:Days:=thursday; 5:Days:=friday; 6:Days:=saturday; end; if Days=saturday then NextDay:=sunday else NextDay:=succ(Days); case NextDay of sunday:Result:='sunday'; monday:Result:='monday'; tuesday:Result:='tuesday'; wednesday:Result:='wednesday'; thursday:Result:='thursday'; friday:Result:='friday'; saturday:Result:='saturday'; end; Result:='明天是'+Result+' 呀!' ; end; procedure TForm1.Button4Click(Sender: TObject); begin ShowMessage(weekday(StrToInt(InputBox('輸入提示框','請輸入0~6之間的任一數字: ','0')))); end; procedure TForm1.Button5Click(Sender: TObject); type chars='A'..'Z'; ints=0..9; var k1,k2,k3,k4:chars; k5,sum:Integer; begin sum:=0; for k1:='A'to 'Z' do for k2:='A'to 'Z'do for k3:='A'to 'Z' do for k4:='A' to 'Z' do for k5:=0 to 9 do sum:=sum+1; ShowMessage(IntToStr(sum));//4569760 end;