我定义了一个简单的类,mymsg,调用很正常。可以使用。但是关闭程序的时候,会出错,这是为什么?提示:exception eaccessviolation in module project1.exe at 0001b74e.access violation at address 00471b74e in module 'project1.exe'.read of address 64726f8c
=============================
调用如下:
var msg1:mymsg;
begin
msg1.Msg :='hello';
showmessage(msg1.Msg) ;end;
=============================
在unit2中定义的类如下:
unit Unit2;interface uses
Dialogs; type
MyMsg = class(TObject)
private
FMsg: string;
function Getmsg(): string;
procedure Setmsg(Value: string); protected
public
function NullMsg: Boolean;
procedure PrintMsg;
property Msg : string Read GetMsg Write SetMsg;
published
end; implementation{ MyMsg }
function mymsg.Getmsg():string;
begin
result:=fmsg;
end;procedure mymsg.Setmsg(Value:string);
begin
fmsg:=Value;
end;function MyMsg.NullMsg: Boolean;
begin
Result := FMsg = '';
end; procedure MyMsg.PrintMsg;
begin
if IsConsole then
Writeln(FMsg)
else
ShowMessage(FMsg);
end; end.
=============================
调用如下:
var msg1:mymsg;
begin
msg1.Msg :='hello';
showmessage(msg1.Msg) ;end;
=============================
在unit2中定义的类如下:
unit Unit2;interface uses
Dialogs; type
MyMsg = class(TObject)
private
FMsg: string;
function Getmsg(): string;
procedure Setmsg(Value: string); protected
public
function NullMsg: Boolean;
procedure PrintMsg;
property Msg : string Read GetMsg Write SetMsg;
published
end; implementation{ MyMsg }
function mymsg.Getmsg():string;
begin
result:=fmsg;
end;procedure mymsg.Setmsg(Value:string);
begin
fmsg:=Value;
end;function MyMsg.NullMsg: Boolean;
begin
Result := FMsg = '';
end; procedure MyMsg.PrintMsg;
begin
if IsConsole then
Writeln(FMsg)
else
ShowMessage(FMsg);
end; end.
解决方案 »
- delphi串口通信
- 请问如何在DevExpress中的DevExpressVcl控件包中的皮肤控件添置和删除皮肤?
- 如何判断打印机是否安装?
- 怎样在表中有text字段的情况下使用distinct?
- delphi调用VC写的Dll报错
- 关于GLScene中GLCube贴图的问题
- 关于三层的简单问题
- 怎样遍历一个目录里的所有文件并取得文件名?
- 三层服务器在Internet上如何屏蔽非法用户?(SOS!200分!)
- <<如何用DELPHI或者VB来提取并且编辑MP3文件中的歌曲信息啊???>>
- 关于datetimepicker控件的问题!急!
- 怎样让windows98只运行自己的程序(另外开帖200答谢)
begin
msg1:=mymsg.create;
....
var
msg1:mymsg;
begin
msg1:=mymsg.create;
try
......
finally
msg1.free;
end;
end;