博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
raise指令触发异常实例
阅读量:4596 次
发布时间:2019-06-09

本文共 903 字,大约阅读时间需要 3 分钟。

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.

 

转载于:https://www.cnblogs.com/endsnow/archive/2011/12/08/2280711.html

你可能感兴趣的文章
EntityFramework 7 Join Count LongCount 奇怪问题(已修复)
查看>>
设计模式---组件协作模式之模板方法模式(Tempalte Method)
查看>>
程序员心理看WEB开发框架
查看>>
@Data 注解在实体类的使用可省去生成GET,SET方法
查看>>
webpack 介绍 & 安装 & 常用命令
查看>>
ASP.NET刷新页面的六种方法总结
查看>>
ECSHOP增加独立评论页面,并分页显示
查看>>
linux date -s
查看>>
jQuery实现可编辑表格
查看>>
Java实验三
查看>>
算法的评价
查看>>
python学习笔记(二)
查看>>
综合云平台 - GlusterFS - 03
查看>>
地球总在不停地转,时间总是不停地走
查看>>
3章 项目属性配置
查看>>
10 华电内部文档搜索系统 search05
查看>>
InterlliJ IDEA 创建maven的web项目并部署
查看>>
提交到SVN中的项目被删除 且项目名已经被新建项目占用找回方法
查看>>
Word2010_2003页眉有条横线怎么删掉
查看>>
qwq
查看>>