delphi7中使用pchar('1')报错
unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,F...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
ComboBox2: TComboBox;
procedure FormActivate(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
ComboBox2.Clear;
ComboBox2.AddItem('是',TObject(pchar('1')));
ComboBox2.AddItem('否',TObject(pchar('2')));
ComboBox2.ItemIndex := 1;
end;
procedure TForm1.ComboBox2Change(Sender: TObject);
var str : String;
begin
str := '1';
showmessage(pchar('1'));
end;
end.
在调用showmessage(pchar('1'));
时报错
改成showmessage(pchar('10'));就能正常编译并整形,高手告诉我是什么原因呀 展开
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
ComboBox2: TComboBox;
procedure FormActivate(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
ComboBox2.Clear;
ComboBox2.AddItem('是',TObject(pchar('1')));
ComboBox2.AddItem('否',TObject(pchar('2')));
ComboBox2.ItemIndex := 1;
end;
procedure TForm1.ComboBox2Change(Sender: TObject);
var str : String;
begin
str := '1';
showmessage(pchar('1'));
end;
end.
在调用showmessage(pchar('1'));
时报错
改成showmessage(pchar('10'));就能正常编译并整形,高手告诉我是什么原因呀 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询