delphi case of


本文整理自网络,侵删。

 
uses
  Character;

procedure TForm1.Button1Click(Sender: TObject);
var
  number: Integer;
  aText: string;
begin
  number := Trunc(NumberBox1.Value);
  case number of
    1: aText := 'One';
    2: aText := 'Two';
    3: aText := 'Three';
  end;
  if aText <> '' then
    Show(aText);
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  aChar: Char;
  aText: string;
begin
  /// multiple nested if statements
  if Edit1.Text.Length > 0 then
  begin
    aChar := Edit1.Text.Chars[0];

    case aChar of
      '+' : aText := 'Plus sign';
      '-' : aText := 'Minus sign';
      '*', '/': aText := 'Multiplication or division';
      '0'..'9': aText := 'Number';
      'a'..'z': aText := 'Lowercase character';
      'A'..'Z': aText := 'Uppercase character';
      #12032..#12255: aText := 'Kangxi Radical';
    else
      aText := 'Other character: ' + aChar;
    end;

    Show(aText);
  end;
end;

procedure TForm1.Show(const msg: string);
begin
  Memo1.Lines.Add(msg);
end;

相关阅读 >>

Delphi 转换一批.bmp 文件为 .jpg

Delphi dbgrid支持鼠标滚轮浏览数据

Delphi 内存管理[2-3]

Delphi 一个定时器timer1相关的简单例子

Delphi 实现显示文件目录大小

Delphi xe5实现通过tmemorystream将一个unicodestring写入到一个unicode文本文件

Delphi从全路径中分离路径,有'\'

Delphi ipnumberipv4

Delphi中控件数组批量赋值

Delphi hmacsha256

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...