zoukankan      html  css  js  c++  java
  • 枚举方式 Case of 判断英文字符串

     
    //对汉字无效
     
    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/ >
     




  • 相关阅读:
    python-登录小游戏
    easyclick 学习
    PYQT5 学习
    Pycharm之QT配置
    标贴打印机的基本使用
    开发遇到的问题及其解决
    Datatable 数据源
    JIRA操作之JQL
    类视图函数 VIEW
    前端基础
  • 原文地址:https://www.cnblogs.com/xe2011/p/2527317.html
Copyright © 2011-2022 走看看