枚举方式 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)
相关文章推荐
- 判断字符串中是否存在的几种方案:string.indexof、string.contains、list.contains、list.any几种方式效率对比
- c#中判断对象为空的几种方式(字符串等)
- PHP判断字符串是纯英文、纯汉字或汉英混合
- JS判断字符串长度(中文2字符,英文1字符),可调整
- JavaSE8基础 String equalsIgnoreCase 判断两个字符串的内容是否相同 (不区分大小写)
- VBA 判断字符串含中文、英文、数字(亲自实践)
- javascript获得字符串实际长度,中文2,英文1(一般微薄都是这个判断)
- C# 使用正则表达式判断字符串是否由英文或数字组成
- 判断字符串为空的几种方式比较
- 拨号、断网、枚举连接名称,判断是否在线、连接方式
- 课后作业——用lastIndexOf判断是否是字符串的最后一位
- 回复:String中如果有中文,如何保证length()返回的长度 在 Java 中字符串是以 Unicode 方式编码的,所以,无论中英文都算的长度为 1。根据你的描述,估计是想要取得英文长度为 1 中文长度为 2 的总长度吧。这个,理论上可以构造 An
- [leetcode 318]Maximum Product of Word Lengths--判断两个字符串是否有相同的字符
- Struts2 用 s:if test 判断属性和字符串相等(特殊的方式)
- 判断字符是否是汉字,ByteType字符串中判断是否英文
- iOS--判断字符串NSString中数字、中文、大小写英文
- JS:1.8字符串(string)对象(length,indexOf(),lastIndexOf(),replace(),match(),toUpperCase(),toLowerCase())
- 如何判断一个字符串是java代码还是英文单词?
- 求助:如何判断输入的字符串为英文字母……
- 拨号、断网、枚举连接名称,判断是否在线、连接方式