欲编一个测试打字速度的小软件,求测每分钟打字速度的公式!(200分相送。) 在窗体上放一个MEMO控件,和一开始按钮。在点开始按钮时,程序开始计时。。然后在MEMO的CHANGE事件里用的公式来算打打速度。。我想是用总字数来除所用时间数。。不知在代码上该如何体现。。如能解决另开100分相送:) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 将现在时间减按开始时的时间 赋给t1length(memo1.text)/t1 就行了。length(memo1.text)为integer值,每个汉字长度为2,每个英文为1。回车换行符为2 打字速度是指汉字速度还是字母速度在memo中可以输入汉字也可以输入英文字母和数字如果不管汉字还是字母都算一个的话,仅仅用length是不可以的计算打字速度在onchange事件中是不合适的,建议另外加一个停止按钮,这个按钮停止开始计算打字速度首先定义一个全局变量start:TDateTime;在开始按钮的onclick事件中添加代码start:=now;memo1.readonly:=false;memo1.setfocus在停止按钮的onclick事件中添加代码present:=now;t:=(now-start)*24*60;m:=0;n:=0;s:=form1.Memo1.Lines.Text;i:=length(form1.Memo1.Lines.Text);for j:=0 to i-1 dobeginif ord(s[j])>127 then m:=m+1else n:=n+1;//字母、数字个数end;m1:=m div 2; //汉字、回车个数v:=(m1+n)/t //汉字、字母等都算一个字的速度v:=(m1+n/2)/t // 汉字的打字速度v:=(m1*2+n)/t //字母的打字速度 我这个例子是实时的,有点像《金山打字通》:1.放一个Memo、一个Timer、两个Button、三个Edit2.Button1:开始按钮 Button2:停止按钮 Edit1:时间(秒) Edit2:总字数 Edit3:速度(字/秒)3.设置Timer1.Interval:=1000; Timer1.Enabled:=False;4.声明全局变量: var T,C:Integer; V:Real;5.在Timer内加入代码: T:=T+1; C:=Length(Memo1.Lines.Text); V:=C/T; Edit1.Text:=IntToStr(T); Edit2.Text:=IntToStr(C); Edit3.Text:=FloatToStr(V);6.在开始按钮的Click加入代码: Timer1.Enabled:=true;7.在停止按钮的Click加入代码: Timer1.Enabled:=false;8.完成!//-------全部源代码------------------------unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; Button2: TButton; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Timer1: TTimer; procedure Timer1Timer(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementationvar T, C: Integer; V: Real; {$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);begin T := T + 1; C := Length(Memo1.Lines.Text); V := C / T; Edit1.Text := IntToStr(T); Edit2.Text := IntToStr(C); Edit3.Text := FloatToStr(V);end;procedure TForm1.Button1Click(Sender: TObject);begin Timer1.Enabled := True;end;procedure TForm1.Button2Click(Sender: TObject);begin Timer1.Enabled := False;end;end.//-------by (Graet)SuperYoyoNC------------------ 更正一下!开始按钮的Click加上Memo1.Setfocus; 高分求助各位:从三方软件内获得URL地址 我咋就这么菜。。线程为什么会自己停止? idTCPClient.ReadLn和timer问题,网络高手指点 Excel中的数据如何导入access或者sql server 怎样获得硬盘序列号? MCISendCommand问题 indy10的 IdUDPServer问题 删除表中重复的行 关于DirectX的问题 如何把combobox里选择到text的简单应用(菜鸟)。马上给分 如何将dbgrid或dbgrideh中的数据转换成dbf(foxpro)格式的文件? ado+sqlserver进行数据库开发要注意哪些资源的释放
length(memo1.text)/t1 就行了。
length(memo1.text)为integer值,每个汉字长度为2,每个英文为1。回车换行符为2
在memo中可以输入汉字也可以输入英文字母和数字
如果不管汉字还是字母都算一个的话,仅仅用length是不可以的
计算打字速度在onchange事件中是不合适的,建议另外加一个停止按钮,这个按钮停止开始计算打字速度
首先定义一个全局变量start:TDateTime;
在开始按钮的onclick事件中添加代码
start:=now;
memo1.readonly:=false;
memo1.setfocus
在停止按钮的onclick事件中添加代码
present:=now;
t:=(now-start)*24*60;
m:=0;
n:=0;
s:=form1.Memo1.Lines.Text;
i:=length(form1.Memo1.Lines.Text);
for j:=0 to i-1 do
begin
if ord(s[j])>127 then
m:=m+1
else
n:=n+1;//字母、数字个数
end;
m1:=m div 2; //汉字、回车个数
v:=(m1+n)/t //汉字、字母等都算一个字的速度
v:=(m1+n/2)/t // 汉字的打字速度
v:=(m1*2+n)/t //字母的打字速度
1.放一个Memo、一个Timer、两个Button、三个Edit
2.Button1:开始按钮
Button2:停止按钮
Edit1:时间(秒)
Edit2:总字数
Edit3:速度(字/秒)
3.设置Timer1.Interval:=1000;
Timer1.Enabled:=False;
4.声明全局变量:
var
T,C:Integer;
V:Real;
5.在Timer内加入代码:
T:=T+1;
C:=Length(Memo1.Lines.Text);
V:=C/T;
Edit1.Text:=IntToStr(T);
Edit2.Text:=IntToStr(C);
Edit3.Text:=FloatToStr(V);
6.在开始按钮的Click加入代码:
Timer1.Enabled:=true;
7.在停止按钮的Click加入代码:
Timer1.Enabled:=false;
8.完成!//-------全部源代码------------------------
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationvar
T, C: Integer;
V: Real; {$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
begin
T := T + 1;
C := Length(Memo1.Lines.Text);
V := C / T;
Edit1.Text := IntToStr(T);
Edit2.Text := IntToStr(C);
Edit3.Text := FloatToStr(V);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled := True;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled := False;
end;end.
//-------by (Graet)SuperYoyoNC------------------
开始按钮的Click加上Memo1.Setfocus;