delphi 中record如何定义以及调用?
先定义了一个记录TOwnBook=recordCode:string;Name:string;Price:string;OwnDays:integer;end;然后在后面...
先定义了一个记录TOwnBook = record
Code : string;
Name : string;
Price : string;
OwnDays : integer;
end;
然后在后面又定义了一个变量tempOwnBook为TOwnBook类型。
结果提示 constant or type identifier expected
代码如下:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, DB, ADODB, Mask, ExtCtrls;
type
TForm4 = class(TForm)
GroupBox1: TGroupBox;
Panel1: TPanel;
StaticText1: TStaticText;
StaticText2: TStaticText;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
StaticText7: TStaticText;
ComboBox1: TComboBox;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOConnection1: TADOConnection;
DataSource1: TDataSource;
DBMemo1: TDBMemo;
StaticText8: TStaticText;
StaticText9: TStaticText;
StaticText10: TStaticText;
StaticText11: TStaticText;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ADOTable1: TADOTable;
ADOQuery3: TADOQuery;
procedure Button3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
TOwnBook : record //定义在此处 是不是因为定义的位置不对?
Code : string;
Name : string;
Price : string;
OwnDays : integer;
end;
....
procedure TForm4.Button1Click(Sender: TObject);
var
tempOwnBook:TOwnBook; //变量定义在此处
begin
...
end.
希望懂的朋友帮忙改正一下 本人QQ263534219 如果能+QQ交流可追加财富悬赏 感激不尽 展开
Code : string;
Name : string;
Price : string;
OwnDays : integer;
end;
然后在后面又定义了一个变量tempOwnBook为TOwnBook类型。
结果提示 constant or type identifier expected
代码如下:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, DB, ADODB, Mask, ExtCtrls;
type
TForm4 = class(TForm)
GroupBox1: TGroupBox;
Panel1: TPanel;
StaticText1: TStaticText;
StaticText2: TStaticText;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
StaticText7: TStaticText;
ComboBox1: TComboBox;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOConnection1: TADOConnection;
DataSource1: TDataSource;
DBMemo1: TDBMemo;
StaticText8: TStaticText;
StaticText9: TStaticText;
StaticText10: TStaticText;
StaticText11: TStaticText;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ADOTable1: TADOTable;
ADOQuery3: TADOQuery;
procedure Button3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
TOwnBook : record //定义在此处 是不是因为定义的位置不对?
Code : string;
Name : string;
Price : string;
OwnDays : integer;
end;
....
procedure TForm4.Button1Click(Sender: TObject);
var
tempOwnBook:TOwnBook; //变量定义在此处
begin
...
end.
希望懂的朋友帮忙改正一下 本人QQ263534219 如果能+QQ交流可追加财富悬赏 感激不尽 展开
展开全部
TOwnBook : record 前缺少关键字type以及TownBook与record之间是=号不是:号
应该这样
type
TownBook = record
Code : string;
Name : string;
Price : string;
OwnDays : integer;
end;
位置可以放在这里,不过按照书写代码的风格建议放到
var
Form4: TForm4;这两句的上面,这样一来比较划分区域,代码也显得好看些
调用没有错,就只是那一句错了.
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, DB, ADODB, Mask, ExtCtrls;
type
TForm4 = class(TForm)
GroupBox1: TGroupBox;
Panel1: TPanel;
StaticText1: TStaticText;
StaticText2: TStaticText;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
StaticText7: TStaticText;
ComboBox1: TComboBox;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOConnection1: TADOConnection;
DataSource1: TDataSource;
DBMemo1: TDBMemo;
StaticText8: TStaticText;
StaticText9: TStaticText;
StaticText10: TStaticText;
StaticText11: TStaticText;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ADOTable1: TADOTable;
ADOQuery3: TADOQuery;
procedure Button3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TOwnBook = record //定义在此处 是不是因为定义的位置不对?
Code : string;
Name : string;
Price : string;
OwnDays : integer;
end;
var
Form4: TForm4;
procedure TForm4.Button1Click(Sender: TObject);
var
tempOwnBook:TOwnBook; //变量定义在此处
begin
...
end.
应该这样
type
TownBook = record
Code : string;
Name : string;
Price : string;
OwnDays : integer;
end;
位置可以放在这里,不过按照书写代码的风格建议放到
var
Form4: TForm4;这两句的上面,这样一来比较划分区域,代码也显得好看些
调用没有错,就只是那一句错了.
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, DB, ADODB, Mask, ExtCtrls;
type
TForm4 = class(TForm)
GroupBox1: TGroupBox;
Panel1: TPanel;
StaticText1: TStaticText;
StaticText2: TStaticText;
StaticText3: TStaticText;
StaticText4: TStaticText;
StaticText5: TStaticText;
StaticText6: TStaticText;
StaticText7: TStaticText;
ComboBox1: TComboBox;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBEdit5: TDBEdit;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOConnection1: TADOConnection;
DataSource1: TDataSource;
DBMemo1: TDBMemo;
StaticText8: TStaticText;
StaticText9: TStaticText;
StaticText10: TStaticText;
StaticText11: TStaticText;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ADOTable1: TADOTable;
ADOQuery3: TADOQuery;
procedure Button3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TOwnBook = record //定义在此处 是不是因为定义的位置不对?
Code : string;
Name : string;
Price : string;
OwnDays : integer;
end;
var
Form4: TForm4;
procedure TForm4.Button1Click(Sender: TObject);
var
tempOwnBook:TOwnBook; //变量定义在此处
begin
...
end.
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询