procedure TForm1.Button2Click(Sender: TObject); var pmyfile:textfile; pstr:string; I: Integer; begin assignfile(pmyfile,'namexxx.txt') ; reset(pmyfile); i:=0 ;
while not eof(pmyfile) do begin readln(pmyfile,pstr); next; i:=i+1; end; closefile(pmyfile); setlength(names,i); showmessage(inttostr(length(names)));
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var p:Tpoint; begin getcursorpos(p); case Key of vk_space: begin if rzbutton1.Caption = '按空格键开始抽取' then begin timer1.Enabled:=true; rzbutton1.Caption := '按空格键停止抽取' ; end else if (p.X >=500) and (rzbutton1.Caption = '按空格键停止抽取') then begin timer1.Enabled :=false ; messagebox(0,PChar(rzdblabel1.Caption),'提示',MB_OK) ; rzbutton1.Caption := '按空格键开始抽取' ; end else if (p.X <500) and (rzbutton1.Caption = '按空格键停止抽取') then begin timer1.Enabled :=false ; rzdblabel1.Caption:='某公司,某人,111111'; messagebox(0,PChar(rzdblabel1.Caption),'提示',MB_OK) ; rzbutton1.Caption := '按空格键开始抽取' ; end;