主题:看看下面的问题
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TKeyGen = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
KeyGen: TKeyGen;
implementation
{$R *.dfm}
procedure TKeyGen.Button1Click(Sender: TObject);
function KeyGen(Name: string): string;
var
n, tmp, Len: integer;
res: string;
begin
Len := Length(Name);
if Len < 6 then
begin
Result := '用户名太短...';
exit;
end;
if Trim(Name) <> Name then
begin
Result := '用户名前后不能含空格';
exit;
end;
Name := UpperCase(Name);
for n := 1 to Len do
begin
if n mod 2 = 0 then
tmp := n * 3 + ord(Name[n])
else
tmp := n * (-3) + ord(Name[n]);
if (tmp < $30) then
res := res + '@'
else if (tmp > $69) then res := res + '*'
else
res := res + Chr(tmp);
end;
Result := res;
end;
=====================
错误
[Error] Unit1.pas(83): Declaration expected but end of file found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
看看错在哪里?
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TKeyGen = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
KeyGen: TKeyGen;
implementation
{$R *.dfm}
procedure TKeyGen.Button1Click(Sender: TObject);
function KeyGen(Name: string): string;
var
n, tmp, Len: integer;
res: string;
begin
Len := Length(Name);
if Len < 6 then
begin
Result := '用户名太短...';
exit;
end;
if Trim(Name) <> Name then
begin
Result := '用户名前后不能含空格';
exit;
end;
Name := UpperCase(Name);
for n := 1 to Len do
begin
if n mod 2 = 0 then
tmp := n * 3 + ord(Name[n])
else
tmp := n * (-3) + ord(Name[n]);
if (tmp < $30) then
res := res + '@'
else if (tmp > $69) then res := res + '*'
else
res := res + Chr(tmp);
end;
Result := res;
end;
=====================
错误
[Error] Unit1.pas(83): Declaration expected but end of file found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
看看错在哪里?