.


:




:

































 

 

 

 





4

 

( Case, ListBox).

 

 

:

..

 

 

2009 .

 

(Case) Object Pascal.

 

2. .

case

, , if. , , .

Delphi case, . :

case of 1:

begin

{ 1 } end; 2:

begin

{ 2 } end; 3:

begin

{ N }

end;

else

begin

{ )

end;

end;

:

- , ( , );

N - . , , . , 1, 2, 3, 4, 5, 6 1..6.

case :

1. -.

2. - .

3. , . s .

4. - , , else.

case else . , , case .

1.7 , case.

. 1.7. , case

case.

case n_day of

1,2,3,4,5: day:=' . ';

6: day:=' Cyoa!';

7: day:='!';

end;

case n_day of

1..5: day:=' .';

6: day:='!';

7: day:='!';

end;

case n_day of

6: day:='!';

7: day:='!';

else day:=' .';

end;

 

3. ϳ .

3.1. ϳ ;

3.2. ;

3.3. .

4.

1) , Case

2) CASE

3) , ?

4) Delphi?

5) Delphi?

6) Delphi?

 

5.1. Windows;

5.2. Delphi

 

 

6.1. Delphi;

6.2. ( 1 2) Delphi:

6.3. , Case

6.4. ( 1 2) Delphi:

1. case , . , "" -. , 409,5 , 볿 - 453,592 , ͳ, 䳿 500 .

, 1.8, .

. 1.8. ij case

ListBox. ListBox Standard ( 1.9). , , , . 1.5 ListBox.

. 1.9. ListBox

1.5. ListBox

Name ' .
Items
Itemindex .
Left ³
Top ³
Height
Width
Font ,
Parent-Font

Items Itemindex. items .

itemindex . , .

.

Object Inspector items ( 1.10).

. 1.10.

, , String List Editor (. 1.11) , . ϳ <Enter>. ϳ <Enter> . , .

. 1.11.

1.6 , 1.7 .

1.6.

ListBoxl ,
Editl
Label1, Label2, Label3
Label4
Button1

1.7.

Form1.Caption case
Editl. Text  
Label1. Caption ,
Label2.Caption
Label3. Caption
Button1. Caption

, , , . .

1.3 .

˳ 1.3.

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Classes,

Graphics, Controls, Forms, Dialogs, StdCtrls;

type

TForm1 = class(TForm)

Label2: TLabel;

Editl: TEdit; //

Button1: TButton; //

Label1: TLabel;

Label: TLabel;

ListBox1: TListBox; //

Label4: TLabel; // -

procedure FqrmCreate(Sender: TObject);

procedure ButtonlClick(Sender: TObject); private

{ Private declarations } public

{ Public declarations } end;

var

Form1: TForml;

implementation

{$R *.DFM}

procedure TForml.FormCreate(Sender: TObject);

begin

{

ListBox1.items.add('');

ListBox1.items.add('');

ListBox1.iterns.add('');

ListBox1.items.add('ͳ');

ListBox1.iterns.add ('');

ListBoxl.iterns.add('');

ListBox1.iterns.add ('');

ListBox1.items.add ('ͳ'); }

ListBox1.itemindex:=0; end;

procedure TForm1.ButtonlClick(Sender: TObject);

var

funt:real; //

kg:real; //

k:real; //

begin

case ListBoxl.Itemindex of

0: k:=0.4095; //

1: k:=0.453592; //

2:k:=0.56001; //

3..5,7:k:=0.5; // ͳ, , , ͳ

6: k:=0.31762; //

end;

funt:=StrToFloat(Editl.Text);

kg:=k*funt;

label4.caption:=Editl.Text

+ ' . - '

+ FloatToStr(kg,ffFixed, 6,3) + '.';

end;

end.

䳿 FormCreate, ( ). , . , .

 

2. case. , , .

, , , : "", "" "" (123 , 120 , 121 ). , , , , 1.8.

1.8.

,
0, 5, 6, 7, 8, 9
 
2,3,4

, 11, 12, 13, 14. , , "".

ij 1.12, - 1.4. , , 䳿 onKeyPress.

. 1.12. ij

˳ 1.4. ,

unit. rub_l; interface

uses

Windows, Messages, SysUtils,

Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls;

type

TForm1 = class(TForm) Label1: TLabel;

Editl: TEdit; Label2: TLabel;

procedure EditlKeyPress(Sender: TObject; var Key: Char);

private

{ Private declarations } public

{ Public declarations } end;

var

Form1: TForm1;

implementation

{$R *.dfm}

//

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char) var

n: integer; //

r: integer; // n 10

text: string[10]; // ,

begin

if Key = chr(VK_RETURN) then

begin

n:= StrToInt(Editl.Text); if n > 100

then n:=n mod 100;

if (n >= 11) and (n <= 14) then

text:=' ' else begin

r:= n mod 10; case r of

1: text:=' '; 2.. 4: text:=' ';

else text:=' ';

end;

end;

Label2.Caption:= IntToStr(n)+ text; end;

end;

end.

 

7.

7.1. .

7.2. .

7.3. .

7.4. .

 

˳:

1. . Delphi . .2002.

2. 7.0.: BHV.

3. .. Delphi. ., 1999.

 

:

1.

:

 


2:

:

 

 


 





:


: 2016-03-25; !; : 425 |


:

:

- , , .
==> ...

1695 - | 1483 -


© 2015-2024 lektsii.org - -

: 0.051 .