プログラムのソースを教えてください。
http://www.wwlnk.com/boheme/delphi/vbtodel/daf0550.html
Delphi Acid Floor
タイマーのアイコンを貼り付けて
そのイベントに
label1.caption=right(inttostr(10000000 + Random(10000000)),7);
と 書けばいいでしょう。
未確認ですが、こんな感じですね。
タイマーのインターバルは 一瞬の時間を入れます。
あと 表示が 変わらないようでしたら
Application.ProcessMessages;
とか入れたらいいでしょう。
http://www.borland.co.jp/delphi/
Borland:ソフトウェア開発ライフサイクル(SDLC)
URLはダミー。
新規に作ったフォーム(TForm1)にButtonを二つ(Button1とButton2)、
Edit(Edit1)を一つ、Timer(Timer1)を一つ置きます。
Button1はスタートボタン、Button2はストップボタンです。
お好みでCaptionプロパティを変えて下さい。
Edit1のtextプロパティは空欄にしておいた方が良いでしょう。
Timer1はEnabledプロパティをfalse、Intervalプロパティを100位にしておきます。
Intervalの値を小さくすればより短い間隔で7桁の数字が書き換わります。
//Button1のクリックイベント
procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled := true; //タイマーを有効にする
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Randomize;//乱数生成前のおまじない
//1000000〜9999999の値をEdit1のTextに入れる
Edit1.Text :=inttostr(Random(8999999) + 1000000);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled := False; //タイマーを無効にする
end;
ありがとうございます。
ワンクリックで、表示→すぐに非表示とい感じにさせたいのですが、
procedure TForm1.Button1Click(Sender: TObject);
var cnt : Integer ;
begin
cnt := Random(8999999) + 1000000;
Label1.caption :=inttostr(cnt);
???
Label1.caption := ’’;
end;
という感じで、???の部分にタイマーの記述を入れればいい(のかな?)と思うのですが、どうすれば良いでしょうか?
質問の意味を取り違えていたようで・・・
これでどうでしょう?
Button1、Edit1を置いて下さい。
//Button1のクリックイベント
procedure TForm1.Button1Click(Sender: TObject);
const
tt:Integer = 100; //表示時間(ミリ秒単位)
var
t1,t2:Integer;
begin
Randomize;//乱数生成前のおまじない
//1000000〜9999999の値をEdit1のTextに入れる
Edit1.Text := inttostr(Random(8999999) + 1000000);
t1 := GetTickCount;
repeat
begin
T2 := GetTickCount;
Application.ProcessMessages;
end
until T2 - T1 >= TT;
Edit1.Text := ’’;
end;
完璧です。どうもありがとうございました。
ありがとうございます。
しかし、上手くいきません。
質問に追加します。
ボタンを押した時に、7桁の・・・表示させるプログラムのソース。でお願いします。