参考以下循环事例:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,crt;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
hz:word;
count:word;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
repeat;
count:=count+1;
hz:=262;
while hz<=524do
begin
sound(hz);
delay(2000);//延迟2秒
hz:=hz+1;
end;
until
count=10;
nosound;
end;
end.