Delphi – E2071 This type cannot be initialized 

In Delphi, you can’t declare typed constants or initialised variables of file types (including type Text) or the type Variant since they can’t be initialised.

program Produce;

var
  V: Variant = 0;

begin
end.

The example attempts to declare an initialised Variant variable, which is forbidden.

program Solve;

var
  V: Variant;

begin
  V := 0;
end.

The solution is to use an assignment statement to initialise a normal variable.

%d bloggers like this: