用OpenDialog直接弹出对话框procedure TForm1.Button6Click(Sender: TObject); begin if self.OpenDialog1.Execute then self.Memo1.Lines.LoadFromFile(self.OpenDialog1.FileName); end;
procedure TForm1.Button4Click(Sender: TObject); var i,j,m,n:Integer; cou:Integer; s1,s2,s3,s4:WideString; begin s1:=self.Memo1.Lines.Text; s2:=self.Memo2.Lines.Text; i:=Length(s1); j:=Length(s2); cou:=0; if i>j then m:=j else m:=i; for n:=1 to m-1 do begin s3:=s1[n]; s4:=s2[n]; if s1[n]=s2[n] then begin cou:=cou+1; self.ListBox1.Items.Add(s1[n]); end; end; MessageBox(Application.Handle,PChar('相同的字符个数为:'+inttostr(cou)),'信息',MB_OK or MB_ICONINFORMATION); end;那个cou就是这段代码中的cou
begin
if self.OpenDialog1.Execute then
self.Memo1.Lines.LoadFromFile(self.OpenDialog1.FileName);
end;
[Error] Unit1.pas(31): 'THEN' expected but identifier 'Execute' found为什么有这么多的错误啊
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Excel2000, OleServer, StdCtrls, ComCtrls,TLHelp32;type
TForm1 = class(TForm)
Button1: TButton;
ExcelWorksheet1: TExcelWorksheet;
ExcelApplication1: TExcelApplication;
ExcelWorkbook1: TExcelWorkbook;
TreeView1: TTreeView;
Button2: TButton;
Label1: TLabel;
Button3: TButton;
Memo1: TMemo;
Memo2: TMemo;
Button4: TButton;
Button5: TButton;
ListBox1: TListBox;
OpenDialog1: TOpenDialog;
Button6: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Memo2Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
procedure onminsize(var msg:TMessage);message WM_syscommand;
public
{ Public declarations }
start_time,end_time:TDateTime;
l:Real;
i:integer;
begin
end_time:=Now;
l:=(end_time-start_time)*24*3600;
i:=Trunc(l);
self.Label1.Caption:='每秒:'+IntToStr(cou div i);
end;
[Error] Unit1.pas(135): Undeclared identifier: 'cou'
这个是不是也要定义全局啊
[Error] Unit1.pas(135): Undeclared identifier: 'cou'
这个是不是也要定义全局啊
还有那个lable要单击一下才会出现成绩的
procedure TForm1.Button4Click(Sender: TObject);
var
i,j,m,n:Integer;
cou:Integer;
s1,s2,s3,s4:WideString;
begin
s1:=self.Memo1.Lines.Text;
s2:=self.Memo2.Lines.Text;
i:=Length(s1);
j:=Length(s2);
cou:=0;
if i>j then
m:=j
else
m:=i;
for n:=1 to m-1 do
begin
s3:=s1[n];
s4:=s2[n];
if s1[n]=s2[n] then
begin
cou:=cou+1;
self.ListBox1.Items.Add(s1[n]);
end;
end;
MessageBox(Application.Handle,PChar('相同的字符个数为:'+inttostr(cou)),'信息',MB_OK or MB_ICONINFORMATION);
end;那个cou就是这段代码中的cou