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 字符串转换为16进制整数 整数转换为16进制字符串

Delphixe win7、mssql2000、udl

Delphi二值图像投影算法

Delphi使用zlib压缩和解压文件

Delphi 中让嵌入窗体的 webbrowser 控件无边框

Delphi stringgrid常用属性和常用操作

Delphi 正则表达式起步

Delphi playsound(); 停止播放

Delphi之猥琐的webserver实现

Delphi xe6 switch元件简繁问题

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



打赏

取消

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

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

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

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

评论

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