标签:
界面设计如下:
Memo1 一个 Label1 一个 Edit1 一个 Button1 两个
1 unit Unit1; 2 3 interface 4 5 uses 6 Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 7 Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; 8 9 type 10 TForm1 = class(TForm) 11 Button1: TButton; 12 Label1: TLabel; 13 Label2: TLabel; 14 Edit2: TEdit; 15 Button2: TButton; 16 Memo1: TMemo; 17 procedure Button2Click(Sender: TObject); 18 procedure Button1Click(Sender: TObject); 19 private 20 { Private declarations } 21 public 22 { Public declarations } 23 end; 24 25 var 26 Form1: TForm1; 27 28 implementation 29 30 {$R *.dfm} //窗口、控件的位置、初始属性等内容是存放在*.DFM文件里面的,必须使用这个语句。 31 32 procedure TForm1.Button1Click(Sender: TObject); 33 var 34 stringlength:Integer; //定义整形变量,记录字符个数 35 begin 36 stringlength := Memo1.GetTextLen; //把memo1里面输入的字符个数赋值给变量 37 Edit2.Text := IntToStr( stringlength); //显示在Edit2里面 38 end; 39 40 procedure TForm1.Button2Click(Sender: TObject); 41 begin 42 close; //退出 43 end; 44 45 end.
标签:
原文地址:http://www.cnblogs.com/zty123/p/5927753.html