W
wangxian111
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls, ExtCtrls;
type
TMainForm = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Button1: TButton;
Memo1: TMemo;
Edit1: TEdit;
Button2: TButton;
Edit2: TEdit;
ClientSocket1: TClientSocket;
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
procedure Send_Message;
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
procedure TMainForm.Send_Message;
begin
ClientSocket1.Socket.SendText(Edit1.Text);
Edit1.Text:='';
end;
procedure TMainForm.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
s:string;
begin
s:= ClientSocket1.Socket.ReceiveText;
Memo1.Lines.Add('服务器端返回的信息为'+s);
end;
procedure TMainForm.Button2Click(Sender: TObject);
begin
if Button2.Caption='登录' then
begin
Button2.Caption:='断开'
ClientSocket1.Address:=Edit2.Text;
ClientSocket1.Active:=False;
ClientSocket1.Active:=True;
Button1.Enabled:=True;
Edit1.Enabled:=True;
end
else
begin
Button2.Caption:='登录';
ClientSocket1.Active:=False;
Button1.Enabled:=False;
Edit1.Enabled:=False;
end;
end;
procedure TMainForm.Button1Click(Sender: TObject);
begin
Send_Message;
end;
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ClientSocket1.Active then
ClientSocket1.Active:=False;
end;
procedure TMainForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
Send_Message;
end;
end;
end.
上面是源代码,但是在编译的时候碰到这样的问题:
[Error] Unit1.pas(58): Missing operator or semicolon
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
谁能告诉我该怎么解决。
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls, ExtCtrls;
type
TMainForm = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Button1: TButton;
Memo1: TMemo;
Edit1: TEdit;
Button2: TButton;
Edit2: TEdit;
ClientSocket1: TClientSocket;
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
procedure Send_Message;
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
procedure TMainForm.Send_Message;
begin
ClientSocket1.Socket.SendText(Edit1.Text);
Edit1.Text:='';
end;
procedure TMainForm.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
s:string;
begin
s:= ClientSocket1.Socket.ReceiveText;
Memo1.Lines.Add('服务器端返回的信息为'+s);
end;
procedure TMainForm.Button2Click(Sender: TObject);
begin
if Button2.Caption='登录' then
begin
Button2.Caption:='断开'
ClientSocket1.Address:=Edit2.Text;
ClientSocket1.Active:=False;
ClientSocket1.Active:=True;
Button1.Enabled:=True;
Edit1.Enabled:=True;
end
else
begin
Button2.Caption:='登录';
ClientSocket1.Active:=False;
Button1.Enabled:=False;
Edit1.Enabled:=False;
end;
end;
procedure TMainForm.Button1Click(Sender: TObject);
begin
Send_Message;
end;
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ClientSocket1.Active then
ClientSocket1.Active:=False;
end;
procedure TMainForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
Send_Message;
end;
end;
end.
上面是源代码,但是在编译的时候碰到这样的问题:
[Error] Unit1.pas(58): Missing operator or semicolon
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
谁能告诉我该怎么解决。