用delphi7怎么做一个抽奖程序

用delphi7怎么做一个抽奖程序,第1张

在窗体中放入label、button、timer、memo 四种类型的控件各一个:

label1--用于显示手机号码的滚动

timer1(时钟)--用于产生随机的手机号码

button1--点击即抽奖,并将获奖号码保存到memo1中

memo1--用于保存获奖手机号码

unit Unit1

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, ExtCtrls

type

  TForm1 = class(TForm)

    Label1: TLabel

    Button1: TButton

    Timer1: TTimer

    Memo1: TMemo

    procedure Timer1Timer(Sender: TObject)

    procedure FormCreate(Sender: TObject)

    procedure Button1Click(Sender: TObject)

  private

    { Private declarations }

  public

    { Public declarations }

  end

const

n=20

a:array[1..n] of string[11]=('13607193000','13607193001',

'13607193002','13607193003','13607193004',

'13607193005','13607193006','13607193007',

'13607193008','13607193009',

'13607193010','13607193011','13607193012',

'13607193013','13607193014',

'13607193015','13607193016','13607193017',

'13607193018','13607193019')  

var

  Form1: TForm1

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject)

var

k:integer

begin

k:=trunc(n*random+1)

  label1.Caption:=a[k]

end

procedure TForm1.FormCreate(Sender: TObject)

begin

      randomize

end

procedure TForm1.Button1Click(Sender: TObject)

begin

  memo1.Lines.Add(label1.Caption)

end

end.

.版本 2

.程序集 窗口程序集1

.程序集变量 位数, 整数型

.子程序 _按钮1_被单击

编辑框2.内容 = “”

.如果 (编辑框1.内容 = “”)

位数 = 取随机数 (1, 10)

.否则

位数 = 到整数 (编辑框1.内容)

.如果结束

.计次循环首 (位数, )

编辑框2.加入文本 (到文本 (取随机数 (0, 9)))

延时 (100)

.计次循环尾 ()


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/11922841.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-19
下一篇2023-05-19

发表评论

登录后才能评论

评论列表(0条)

    保存