Learn Programming and technology with ease @ developerpublish.com

HomeDelphiDelphi Error â€“ E2030 Duplicate case label

# Delphi Error â€“ E2030 Duplicate case label

## Delphi Compiler Error

E2030 Duplicate case label

## Reason for the Error & Solution

This error message occurs when there is more than one case label with a given value in a case statement.

```program Produce;

function DigitCount(I: Integer): Integer;
begin
case Abs(I) of
0                     DigitCountÂ := 1;
0        ..9         DigitCountÂ := 1;   (*<-- Error message here*)
10       ..99        DigitCountÂ := 2;
100      ..999       DigitCountÂ := 3;
1000     ..9999      DigitCountÂ := 4;
10000    ..99999     DigitCountÂ := 5;
100000   ..999999    DigitCountÂ := 6;
1000000  ..9999999   DigitCountÂ := 7;
10000000 ..99999999  DigitCountÂ := 8;
100000000..999999999 DigitCountÂ := 9;
else                  DigitCountÂ := 10;
end;
end;

begin
Writeln( DigitCount(12345) );
end.

```

Here we did not pay attention and mentioned the case label 0 twice.

```program Solve;

function DigitCount(I: Integer): Integer;
begin
case Abs(I) of
0        ..9         DigitCountÂ := 1;
10       ..99        DigitCountÂ := 2;
100      ..999       DigitCountÂ := 3;
1000     ..9999      DigitCountÂ := 4;
10000    ..99999     DigitCountÂ := 5;
100000   ..999999    DigitCountÂ := 6;
1000000  ..9999999   DigitCountÂ := 7;
10000000 ..99999999  DigitCountÂ := 8;
100000000..999999999 DigitCountÂ := 9;
else                  DigitCountÂ := 10;
end;
end;

begin
Writeln( DigitCount(12345) );
end.

```

In general, the problem might not be so easy to spot when you have symbolic constants and ranges of case labels â€“ you might have to write down the real values of the constants to find out what is wrong.

Share:

### You May Also Like

#### Delphi Error â€“ X2421 Imported identifier â€˜%sâ€™ conflicts with â€˜%sâ€™ in â€˜%sâ€™

Delphi Compiler Error X2421 Imported identifier â€˜%sâ€™ conflicts with â€˜%sâ€™ in â€˜%sâ€™ Reason for the Error & Solution This occurs...

#### Delphi Error â€“ X2367 Case of property accessor method %s.%s should be %s.%s

Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...

#### Delphi Error â€“ X2269 Overriding virtual method â€˜%s.%sâ€™ has lower visibility (%s) than base class â€˜%sâ€™ (%s)

Delphi Compiler Error X2269 Overriding virtual method â€˜%s.%sâ€™ has lower visibility (%s) than base class â€˜%sâ€™ (%s) Reason for the...