[Delphi] Question on Code-Shortening
Posted: Sun Oct 24, 2010 12:53 am
Hmm for people that code in Delphi or VB(since VB is pretty much related to Delphi)
just wanna ask if we could shorten the code below by using sets or arrays
i've tried both but didnt work ><
can we like shorten it to become eg.
your help will be kindly appreciated 
im currently writing a program with 1300 line on codes
and this would definitely shorten it to around 700 lines
just wanna ask if we could shorten the code below by using sets or arrays
i've tried both but didnt work ><
Code: Select all
type
TForm1 = class(TForm)
Image1:TImage;
Image2:TImage;
Image3:TImage;
Image4:TImage;
Image5:TImage;
procedure Button1Click(Sender: TObject);
begin
Image1.Visible := True;
Image2.Visible:= True;
Image3.Visible:= True;
Image4.Visible:= True;
Image5.Visible:= True;
end
end;
end.
Code: Select all
type
TForm1 = class(TForm)
Image1:TImage;
Image2:TImage;
Image3:TImage;
Image4:TImage;
Image5:TImage;
procedure Button1Click(Sender: TObject);
var i : Array of Integer ;
begin
For i 1 to 5 do
Image(i).Visible := True;
end
end;
end.

im currently writing a program with 1300 line on codes
and this would definitely shorten it to around 700 lines