1. 程式人生 > >Delphi 7 9*9乘法口訣表

Delphi 7 9*9乘法口訣表

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
  var i,j:integer;
begin
     for i := 1 to 9 do
          for j :=1 to i do
          form1.Canvas.TextOut(50*j,20*i,inttostr(j)+'*'+inttostr(i)+'='+inttostr(i*j));


end;

procedure TForm1.Button2Click(Sender: TObject);
begin
       if messagedlg('exit',mtInformation,[mbyes,mbno],0)=mryes then
             form1.close;
end;

end.

 程式說明:

1: inttostr(j):應該是整數型資料轉化為字串

2: Canvas屬性TextOut的方法,TextOut(x,y:integer, const text:string)

3: messagedlg : https://www.cnblogs.com/jxsoft/archive/2011/03/09/1978150.html

執行結果如下圖所示: