W
wanglong4
Unregistered / Unconfirmed
GUEST, unregistred user!
我想设置我的idudpserver1控件的本地端口是4000,如果被占用,就加1,为4001,如果又被占用,就再加1,我这么写怎么不对呢??
procedure TForm1.Button2Click(Sender: TObject);
var
de, tag: integer;
begin
de := 4000;
tag := 0;
while tag = 0 do
begin
try
idudpserver1.DefaultPort := de;
idudpserver1.Active := true;
tag := 1;
except
de := de + 1;
end;
end;
showmessage('最终使用了' + inttostr(de) + '端口');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
de, tag: integer;
begin
de := 4000;
tag := 0;
while tag = 0 do
begin
try
idudpserver1.DefaultPort := de;
idudpserver1.Active := true;
tag := 1;
except
de := de + 1;
end;
end;
showmessage('最终使用了' + inttostr(de) + '端口');
end;