您的位置:首页 > 其它

枚举方式 Case of 判断英文字符串

2012-05-31 08:21 246 查看




//对汉字无效

unit Unit1;

interface

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

type
TForm1 = class(TForm)
ComboBox1: TComboBox;

Button1: TButton;

procedure Button1Click(Sender: TObject);
private
{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation
uses TypInfo;
{$R *.dfm}

type
TMyEnum = (Red, black, Green);
procedure TForm1.Button1Click(Sender: TObject);
var
MyEnum: TMyEnum;
str: String;
begin
str := ComboBox1.Text;//输入Red Black Green

MyEnum := TMyEnum(GetEnumvalue(TypeInfo(TMyEnum), str));
case MyEnum of

Red :Self.Caption := '红色';

black :Self.Caption := '黑色';

Green :Self.Caption := '蓝色';
end;
end;
end.

粘贴自: <http://www.cnpack.org/ >

来自为知笔记(Wiz)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐