unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Label1: TLabel; Edit1: TEdit; Edit2: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}type epasswordinvalid = class(exception);procedure TForm1.Button1Click(Sender: TObject);var gpassword: string;begin if edit1.Text <> edit2.Text then begin raise epasswordinvalid.Create('由程序员显示异常信息' + #10 + #13 + '密码输入有误!'); edit2.Text := ''; //此行永远不会被执行 end else begin gpassword := edit1.Text; showmessage('密码设定完成'); end; showmessage('欢迎光临!'); //前面不产生异常时,此行才会执行end;end.