Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shorter Code for Clear function.. Help.. 1

Status
Not open for further replies.

beginner81

Programmer
Oct 27, 2003
44
MY
Hello forums.. i wonder is that anyway for me to using a single code to clear all the fields in a form after i click at the Clear button?? ... instead of putting the code like TEdit1.Clear; TEdit2.Clear; TEdit3.Clear.. is that anyway for me to do so?? thx ..
 
You could try something akin to the following code snippet:

var
LoopX : Integer;
begin
for LoopX = 0 to Form1.ControlCount do
if Form1.Controls[LoopX] is TEdit then
(Form1.Controls[LoopX] as TEdit).Clear;
end;
 
Whoops, change

for LoopX = 0 to Form1.ControlCount do

to

for LoopX = 0 to Form1.ControlCount - 1 do
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top