tem como redufir simplificar esta rotina com varios componen

09/07/2004

0

tem como redufir simplificar esta rotina com varios componentes ?
to usando 10 componentes webbrowser to achando a rotina grande sera que da para reduzir?

procedure TForm1.Button2Click(Sender: TObject);
var
web : string;
begin
web:=´www.pgna.com.br´;

if Edit9.Text = ´1´ then
begin
Webbrowser1.Navigate(cam);

end;
if Edit9.Text = ´2´ then
begin
Webbrowser1.Navigate(cam);
Webbrowser2.Navigate(cam);
end;
if Edit9.Text = ´3´ then
begin
Webbrowser1.Navigate(cam);
Webbrowser2.Navigate(cam);
Webbrowser3.Navigate(cam);
end;
if Edit9.Text = ´4´ then
begin
Webbrowser1.Navigate(cam);
Webbrowser2.Navigate(cam);
Webbrowser3.Navigate(cam);
Webbrowser4.Navigate(cam);
end;
if Edit9.Text = ´5´ then
begin
Webbrowser1.Navigate(cam);
Webbrowser2.Navigate(cam);
Webbrowser3.Navigate(cam);
Webbrowser4.Navigate(cam);
Webbrowser5.Navigate(cam);
end;
if Edit9.Text = ´6´ then
begin
Webbrowser1.Navigate(cam);
Webbrowser2.Navigate(cam);
Webbrowser3.Navigate(cam);
Webbrowser4.Navigate(cam);
Webbrowser5.Navigate(cam);
Webbrowser6.Navigate(cam);
end;
if Edit9.Text = ´7´ then
begin
Webbrowser1.Navigate(cam);
Webbrowser2.Navigate(cam);
Webbrowser3.Navigate(cam);
Webbrowser4.Navigate(cam);
Webbrowser5.Navigate(cam);
Webbrowser6.Navigate(cam);
Webbrowser7.Navigate(cam);
end;
if Edit9.Text = ´8´ then
begin
Webbrowser1.Navigate(cam);
Webbrowser2.Navigate(cam);
Webbrowser3.Navigate(cam);
Webbrowser4.Navigate(cam);
Webbrowser5.Navigate(cam);
Webbrowser6.Navigate(cam);
Webbrowser7.Navigate(cam);
Webbrowser8.Navigate(cam);
end;
if Edit9.Text = ´9´ then
begin
Webbrowser1.Navigate(cam);
Webbrowser2.Navigate(cam);
Webbrowser3.Navigate(cam);
Webbrowser4.Navigate(cam);
Webbrowser5.Navigate(cam);
Webbrowser6.Navigate(cam);
Webbrowser7.Navigate(cam);
Webbrowser8.Navigate(cam);
Webbrowser9.Navigate(cam);
end;
if Edit9.Text = ´10´ then
begin
Webbrowser1.Navigate(cam);
Webbrowser2.Navigate(cam);
Webbrowser3.Navigate(cam);
Webbrowser4.Navigate(cam);
Webbrowser5.Navigate(cam);
Webbrowser6.Navigate(cam);
Webbrowser7.Navigate(cam);
Webbrowser8.Navigate(cam);
Webbrowser9.Navigate(cam);
Webbrowser10.Navigate(cam);
end;


Flaviocont

Flaviocont

Responder

Posts

09/07/2004

Minuto

faça um loop e
use components


Responder

09/07/2004

Beppe

Como os nomes obedecem a um padrão, vc pode usar FindComponent num loop:

for I := 1 to StrToInt(Edit9.Text) do
begin
  TWebBrowser(FindComponent(´WebBrowser´ + IntToStr(I))).Navigate(cam);
end;



Responder

APRENDA A PROGRAMAR DO ZERO AO PROFISSIONAL

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar