// 它们定义在 System.Character, 它可以彻底替代同单元的 TCharacter 结构体. 主要方法有: function IsControl: Boolean; function IsDigit: Boolean; function IsHighSurrogate: Boolean; function IsInArray(const SomeChars: array of Char): Boolean; function IsLetter: Boolean; function IsLetterOrDigit: Boolean; function IsLower: Boolean; function IsLowSurrogate: Boolean; function IsNumber: Boolean; function IsPunctuation: Boolean; function IsSeparator: Boolean; function IsSurrogate: Boolean; function IsSymbol: Boolean; function IsUpper: Boolean; function IsWhiteSpace: Boolean; function ToLower: Char; function ToUpper: Char; function ToUCS4Char: UCS4Char; // 以后可以不用 CharInSet()了, 不过得引用 System.Character 单元
uses System.Character; procedure TForm1.FormCreate(Sender: TObject); begin KeyPreview := True; end; procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char); begin // if Key.IsInArray(['1', '2', '3', '4', '5', '6', '7', '9', '0']) then // ShowMessage('按下了数字键'); if Key.IsNumber then ShowMessage('真的按下了数字键'); end;