unit1.~pas

来自「Delphi的函数例子」· ~PAS 代码 · 共 47 行

~PAS
47
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,StrUtils;

type
  TForm1 = class(TForm)
    MainBox: TEdit;
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    function Validate(Address: String): Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

function TForm1.Validate(Address: String): Boolean;
begin
  Result := True;
  if PosEx('@',Address,2)=0 then
    Result := False;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    if Validate(MainBox.Text)= False then
    ShowMessage('您输入的邮箱格式不正确.');

end;

end.
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?