Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 如何在不声明200个变量的情况下执行此操作?_String_Delphi_Variables_Pascal - Fatal编程技术网

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

String 如何在不声明200个变量的情况下执行此操作?,string,delphi,variables,pascal,String,Delphi,Variables,Pascal,我想我的问题有解决办法,但我没有找到,你能帮我吗 我想这样做: 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] := IntToS

我想我的问题有解决办法,但我没有找到,你能帮我吗

我想这样做:

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;
但现在我需要声明200个字符串变量,如本例中所示。这有没有“捷径”

这是我尝试的循环:

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

我尝试了一个循环,但没有任何改变请展示您尝试循环的情况。如果您“尝试了一个循环”,请将您的问题也包括在内。您需要学习如何编程。找一本非常基础的书,更仔细地阅读关于循环的部分。你的循环没有添加任何内容。你希望它如何工作?您只需将一个整数更改为一个字符串,然后将相同的单元格内容替换为该字符串200次。然后,您应该接受它作为邀请@NGLN喝啤酒的答案
var
  Total: Integer;
  I: Integer;
begin
  Total := 0;
  for I := 1 to 3 do
    Inc(Total, StrToInt(StringGrid1.Cells[I, 1]));
  StringGrid1.Cells[4, 1] := IntToStr(Total);
end;