Delphi E2029:需要声明但找到文件结尾 - 如何调试?

yes*_*ded 0 delphi pascal vlc

大家好,我出现了一个错误,我无法摆脱..

我在我的 delphi 代码中添加了 2 个自定义过程,我读到你可以点击crtl+shift+c自动生成函数,我做到了。

但是我现在的问题是我不需要自动生成的东西,这就是我在执行命令后删除它的原因。现在我的代码不再工作,因为我收到了这个错误:

应为 E2029 声明但已找到文件结尾

预期初始化,但在第 520 行(520:1)处收到文件结尾

如何修复我的代码?在文件末尾删除或添加“结尾”对我没有帮助。有没有办法找出我的代码中遗漏了什么?(我可以发布我的 delphi 代码,但它的 500 行长我认为这没有意义。

更新代码:

unit Benutzerverwaltung_U;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.ComCtrls,
  Vcl.StdCtrls,
  Vcl.WinXCtrls, Vcl.CheckLst, System.Actions, Vcl.ActnList, Vcl.Menus,
  System.StrUtils,
  Data.DB, Vcl.Grids, Vcl.DBGrids, Vcl.DBCtrls, FireDAC.Stan.Intf,
  FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS,
  FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Comp.DataSet,
  FireDAC.Comp.Client;

type
  TForm1 = class(TForm)
Run Code Online (Sandbox Code Playgroud)

其他按钮等等...

    procedure SwapValues(var Zahl1, Zahl2: Integer); //new
    procedure SelectionSort(Sender: TObject);  // new
    procedure Button11Click(Sender: TObject); //new

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }

    workerModel: record
      VorName: string[40];
      NachName: string[40];
      Age: Integer;
      Schließen: string[30];
      Admin: TToggleSwitchState;
      DatenSehen: TToggleSwitchState;
      Gender: string[20];

    end;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Sonderrechte_U, CheckedItem_U, Unit1, BenutzerEdit_u;


procedure TForm1.SwapValues(var Zahl1, Zahl2: Integer);
var
  h: Integer;
begin
  h := Zahl1;
  Zahl1 := Zahl2;
  Zahl2 := h;
end;

procedure TForm1.SelectionSort(Sender: TObject);
var
  i, j, min: Integer;
var
  sortArray, Data: Array of string;

begin

  for i := 1 to Form1.ListBox1.Items.Count - 1 do
  // i muss wahrscheinlich 0 sein?
  begin
    min := i;
    for j := i + 1 to Form1.ListBox1.Items.Count do
      if (Data[j] < Data[min]) then
        min := j;
    SwapValues(i, min);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2 := TForm2.Create(Self);
  try
    Form2.ShowModal;
  finally
    Form2.Free;
  end;

end;
Run Code Online (Sandbox Code Playgroud)

// 更多代码

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  l: Integer;
  t: String;
begin
  with ListBox1 do
  begin
    Canvas.FillRect(Rect);
    t := Items[Index];
    l := Rect.Right - Canvas.TextWidth(t) - 1;
    Canvas.TextOut(l, Rect.Top, t);
  end;
end;

procedure TForm1.SearchBox1Change(Sender: TObject);

var
  i: Integer;

begin
  // SearchBox1.Parent := ListBox1;

  ListBox1.Items.BeginUpdate;

  try
    for i := 0 to ListBox1.Items.Count - 1 do
      ListBox1.Selected[i] := ContainsText(ListBox1.Items[i], SearchBox1.Text);

  finally
    ListBox1.Items.EndUpdate;


end;
// end;


// this is the end of the file
Run Code Online (Sandbox Code Playgroud)

And*_*and 5

Delphi 单元必须以

end.
Run Code Online (Sandbox Code Playgroud)

(注意句号)。