[Delphi] Question on Code-Shortening

Discuss about Programming here. You may release your source, post guide and even ask questions!

Moderator: wizme

Post Reply
User avatar
KFSPC8
Master of Darkness
Master of Darkness
Posts: 494
Joined: Sat Jun 05, 2010 6:18 pm
Location: Singapore

[Delphi] Question on Code-Shortening

Post by KFSPC8 »

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 ><

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.
 
can we like shorten it to become eg.

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.
 
your help will be kindly appreciated :D
im currently writing a program with 1300 line on codes
and this would definitely shorten it to around 700 lines
Post Reply