1、我刚开始学习Delphi6,以前我对计算机也只是了解一点,需要先学习c语言吗?(我在学习的过程中发现好多语言比如:showmodal、showmessage等不知从那里学到)
2、Label组件的caption属性在运行过程中的赋值怎么是错误的呐?以下错在哪里?*
一个form窗体中有两个组件:label1、button1,
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i,iSum : integer;
XianShi : string;
begin
iSum:=0;
for i:=1 to 100 do
inc(iSum,i);
XianShi:= ' intToStr('iSum') ' ;
label1.caption := 'xianSHi';
//为什么点击button1后labele1显示的是“xianShi”,而不是“5050”?
end;
end.
2、Label组件的caption属性在运行过程中的赋值怎么是错误的呐?以下错在哪里?*
一个form窗体中有两个组件:label1、button1,
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i,iSum : integer;
XianShi : string;
begin
iSum:=0;
for i:=1 to 100 do
inc(iSum,i);
XianShi:= ' intToStr('iSum') ' ;
label1.caption := 'xianSHi';
//为什么点击button1后labele1显示的是“xianShi”,而不是“5050”?
end;
end.
2,label1.caption := intToStr(iSum) ;
'iSum'是字符串,而iSum才是变量
有很多基础事例程序,可以下来参考。
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i,iSum : integer;
XianShi : string;
begin
iSum:=0;
for i:=1 to 100 do
inc(iSum,i);
XianShi:= ' intToStr(iSum) ' ; //=======
label1.caption := xianSHi; //=======
//为什么点击button1后labele1显示的是“xianShi”,而不是“5050”?
end;
end.
老大,我理解你很想升星星的心情,可是也不用这样跟我抢这区区10分吧……
try
Label1.Caption := IntToStr(StrToInt(Edit1.Text) * StrToInt(Edit2.Text));
except
ShowMessage('You must specify integer values. Please try again.');
end;
end;
label1.caption := xianSHi;