zoukankan      html  css  js  c++  java
  • 用一个 Byte 数表示 8 个复选框的选择状态

    unit Unit1;


    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, CheckLst;

    type
      TForm1 
    = class(TForm)
        CheckListBox1: TCheckListBox;
        Button1: TButton;
        Edit1: TEdit;
        
    procedure FormCreate(Sender: TObject);
        
    procedure Button1Click(Sender: TObject);
        
    procedure CheckListBox1Click(Sender: TObject);
      
    end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}

    var
      num: Integer;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Edit1.Text :
    = '输入一个 Byte 数';
      CheckListBox1.Align :
    = alLeft;
      CheckListBox1.Items.CommaText :
    = 'A,B,C,D,E,F,G,H';
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i: Integer;
    begin
      num :
    = Lo(StrToIntDef(Edit1.Text, 0));
      Edit1.Text :
    = IntToStr(num);
      
    for i := 0 to 7 do CheckListBox1.Checked[i] := 1 shl i or num = num;
      Text :
    = IntToStr(num);
    end;

    procedure TForm1.CheckListBox1Click(Sender: TObject);
    var
      i: Integer;
    begin
      num :
    = 0;
      
    for i := 0 to 7 do if CheckListBox1.Checked[i] then num := num or 1 shl i;
      Text :
    = IntToStr(num);
      Edit1.Text :
    = Text;
    end;

    end.
  • 相关阅读:
    阿里云配置mysql远程连接
    [转载]Lodop用户应对谷歌浏览器停用Plugin技术的处理办法
    利用lodop打印控件轻松实现批量打印
    ThinkPHP 中M方法和D方法的具体区别
    Codeforces
    POJ
    HDU
    POJ
    POJ
    HDU
  • 原文地址:https://www.cnblogs.com/jxgxy/p/2087019.html
Copyright © 2011-2022 走看看