E2071 This type cannot be initialized (Delphi)

From RAD Studio
Jump to: navigation, search

Go Up to Error and Warning Messages (Delphi)

File types (including type Text), and the type Variant cannot be initialized, that is, you cannot declare typed constants or initialized variables of these types.


program Produce;

var
  V: Variant = 0;

begin
end.

The example tries to declare an initialized variable of type Variant, which illegal.


program Solve;

var
  V: Variant;

begin
  V := 0;
end.

The solution is to initialize a normal variable with an assignment statement.