//ファイル名:test.js
import System;
import System.Drawing;
import System.Windows.Forms;
import Accessibility;
var f : HelloForm = new HelloForm();
f.Font = new System.Drawing.Font("MS ゴシック", 10);
f.ShowDialog();
class HelloForm extends Form
{
var text1 : TextBox;
var btnDisplay : DisplayButton;
var label1 : Label;
var label2 : Label;
function HelloForm()
{
super();
this.Size = new System.Drawing.Size( 300, 160 );
this.Text = "JScript ループ計算";
label1 = new Label;
label1.Location = new Point(20, 5);
label1.Size = new System.Drawing.Size( 300, 45 );
label1.Text = "for( var i:int=0; i<=N; i++){a[i] = 0;}\n\n数値N を入力";
this.Controls.Add( label1 );
text1 = new TextBox();
text1.Width = 100;
text1.Font = new System.Drawing.Font("MS UI Gothic", 11);
text1.Location = new Point(20, 50);
Controls.Add(text1);
btnDisplay = new DisplayButton();
Controls.Add(btnDisplay);
label2 = new Label;
label2.Size = new System.Drawing.Size( 300, 20 );
label2.Location = new Point(20, 100);
label2.Text = "計算時間 -----------";
this.Controls.Add( label2 );
}
}
class DisplayButton extends Button {
function DisplayButton() {
super();
Text = "GO";
Location = new Point(130, 50);
Size = new System.Drawing.Size( 60, 23 );
}
protected override function OnClick(e : EventArgs) {
var t : int = Environment.TickCount; //時刻設定
var N: int = Number(HelloForm(Parent).text1.Text);
var a : double[] = new double[N+1];
for( var i : int = 0; i<=N; i++){a[ i ] = 0;}
HelloForm(Parent).label2.Text ="計算時間 "+( Environment.TickCount - t) + " ms";
MessageBox.Show("計算完了\n\n a [ " + N + " ] = "+ a[N]);
}
}
|