⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 1、第一次运行
💻 PAS
字号:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    Panel1: TPanel;
    Button1: TButton;
    procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) and(Combobox1.Text<>'') then
   begin
     Combobox1.Items.Insert(0,Combobox1.Text);
     Combobox1.SelStart:=0;
     Combobox1.Text:='';
   end;
   if key=#27 then
     if Combobox1.ItemIndex<>-1 then
        Combobox1.Items.Delete(Combobox1.ItemIndex);
end;

procedure TForm1.Button1Click(Sender: TObject);
var i,m,n:smallint;
begin
m:=0;
n:=0;
i:=combobox1.items.count;
while i>0 do
begin if strtoint(combobox1.Items[i]) mod 2=0 then
m:=m+1
else n:=n+1;
panel1.Caption:='偶数:'+inttostr(m)+'奇数:'+inttostr(n);
i:=i-1;
end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -