A
A
Andrey Lupashko2015-12-15 17:52:36
Delphi
Andrey Lupashko, 2015-12-15 17:52:36

How to switch between variables in Delphi?

For example, I have variables x1,x2,x3...x100. And I need to assign values ​​to all of them. Can this be done using a loop or do I have to manually assign a value?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Martyanov, 2015-12-15
@vilgeforce

Create an array x[100] and fill it in a loop.

O
ORTOL, 2015-12-18
@ORTOL

Hello.
Since you can't do it with variables. As the user Vladimir Martyanov said, Vladimir Martyanov will have to create an array. Here's an example of adding a value in a loop.

procedure TForm1.Button1Click(Sender: TObject);
var
 num: array  [0..100] of Integer;
 i: Integer;
begin
 for i:=0 to 100 do num[i] := num[i] + 5;
end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question