小编use*_*141的帖子

Delphi初学者-在TEdit中使用循环

我有10个TEdits和10个图像,我尝试使用以下方法:

procedure TForm1.Button1Click(Sender: TObject; edit: TEdit);
var i:integer;
begin
for i:= 1 to 10 do
  begin
   if edit[i].text:='1' then picture[i].Show else picture[i].Hide;
  end;
end;
Run Code Online (Sandbox Code Playgroud)

但是delphi返回此错误:[错误] Unit1.pas(84):类没有默认属性

我也试过这个:

procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
for i:= 1 to 10 do
  begin
   if edit[i].text:='1' then picture[i].Show else picture[i].Hide;
  end;
end;
Run Code Online (Sandbox Code Playgroud)

但是,Delphi再次返回错误:

[错误] Unit1.pas(84):未声明的标识符:“编辑”。

你能帮我这个代码吗?

delphi loops image edit

0
推荐指数
2
解决办法
764
查看次数

如何在不声明200个变量的情况下执行此操作?

我认为我的问题有一个解决方案,但我找不到,你能帮助我吗?

我想做这样的事情:

var
  a, b, c: string;
  d: integer;
begin
  a := StringGrid1.Cells[1,1];
  b := StringGrid1.Cells[2,1];
  c := StringGrid1.Cells[3,1];
  d := StrToInt(a) + StrToInt(b) + StrToInt(c);
  StringGrid1.Cells[4,1] := IntToStr(d);
end;
Run Code Online (Sandbox Code Playgroud)

但现在我需要声明200个字符串变量,就像在这个例子中一样.无论如何,这是一个"捷径"吗?

这是我试过的循环:

var
  x: integer;
begin
  for x := 1 to 200 do 
  begin 
    Form2.StringGrid1.Cells[3,209] := IntToStr(x);
  end;
end;
Run Code Online (Sandbox Code Playgroud)

delphi string variables pascal

-4
推荐指数
1
解决办法
227
查看次数

标签 统计

delphi ×2

edit ×1

image ×1

loops ×1

pascal ×1

string ×1

variables ×1