首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

怎么中止循环

2012-04-17 
如何中止循环?for i:0 to 100 dofor j:0 to 100 dobeginif Image1.Canvas.Pixels[i,j]RGB(100,100,100)

如何中止循环?
for i:=0 to 100 do
  for j:=0 to 100 do
  begin
  if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
  begin
  showmessage(IntToStr(i)+','+IntToStr(j));
  end;
  end;
这样一个循环语句,由于RGB值是100,100,100的有很多点,所以会不停的弹提示,我只想要找到第一个就行了,应该怎么写?谢谢!

[解决办法]
for i:=0 to 100 do
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
exit;

end;
end;

[解决办法]
for i:=0 to 100 do
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
exit; end;
end;

[解决办法]
exit;
也可以用
try

failly

end;
-------------------------
try


except

end;
[解决办法]
var
i,j: Integer;
label
_next;
begin
for i:=0 to 100 do
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
goto _next
end;
end;

_next:
showmessage('next')

end;

热点排行