请问有关于宏替换的问题!!谢谢!!(50分)

  • 主题发起人 真不才
  • 开始时间

真不才

Unregistered / Unconfirmed
GUEST, unregistred user!
[red]请问各位大虾,在foxpro下可以用"&"做宏替换,那么在delphi下用什么样的方法能够
实现这个方法咧! 如:
label1,label2,label3 这些其中1,2,3想放到一个循环中负值,要如何实现??
非常感谢!![/red]
 
只能循环,或者findcomponent
ComponentCount
FindComponent
 
for i := 0 to ComponentCount - 1do
if (Components is TLabel) then
(Components as TLabel).Caption := inttostr(i);
 
var
I:Integer;
begin
for I:=0 to Self.ComponentCount -1do
if (Components Is TLabel) then
Tlabel(Components).Caption:=IntToStr(I);
end;
 
用FindCompont:
var s:tobject;
//或者直接设为label变量:s:TLabel;
i:integer;
begin
for i:=1 to 3do

begin
s:=FindComponent('Label'+IntToStr(i));
(s as tLabel).visible:=false;
//如s已设为label变量,直接可以:s.visible:=false;
end;
end;
 
[:D]
谢谢大家的帮助!!!
非常感谢!!!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
950
SUNSTONE的Delphi笔记
S
顶部