Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

電卓をつくっています。

6 views
Skip to first unread message

Y/A

unread,
Oct 10, 2007, 5:45:02 PM10/10/07
to
電卓をつくろうと、簡単なソースからはじめているのですが
テキストボックスに入力された実数を変数に入力する構文がわかりません。
また、計算結果の変数からラベルに実数で出力する方法がわかりません。

どなたかご教授ください。

下記ソース

package WindowsApplication2;

import System.Collections.Generic.*;
import System.Data.*;
import System.Drawing.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;

/**
* Form1 の概要の説明です。
*/
public class Form1 extends System.Windows.Forms.Form
{
private Label label1;
private TextBox textBox1;
private TextBox textBox2;
private Button button1;
/**
* 必要なデザイナ変数です。
*/
private System.ComponentModel.IContainer components;

public Form1()
{
//
// Windows フォーム デザイナのサポートに必要です
//
InitializeComponent();

//
// TODO: InitializeComponent 呼び出しの後でコンストラクタ コードを追加します
//
}

#region Windows フォーム デザイナで生成されたコード
/**
* 使用中のリソースをすべてクリーンアップします。
*/
protected void Dispose(boolean disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
super.Dispose(disposing);
}

/**
* デザイナ サポートに必要なメソッドです。このメソッドの内容を
* コード エディタで変更しないでください。
*/
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.set_AutoSize(true);
this.label1.set_Location(new System.Drawing.Point(12, 109));
this.label1.set_Name("label1");
this.label1.set_Size(new System.Drawing.Size(35, 12));
this.label1.set_TabIndex(0);
this.label1.set_Text("");
//
// textBox1
//
this.textBox1.set_Location(new System.Drawing.Point(14, 22));
this.textBox1.set_Name("textBox1");
this.textBox1.set_Size(new System.Drawing.Size(100, 19));
this.textBox1.set_TabIndex(1);
//
// textBox2
//
this.textBox2.set_Location(new System.Drawing.Point(14, 60));
this.textBox2.set_Name("textBox2");
this.textBox2.set_Size(new System.Drawing.Size(100, 19));
this.textBox2.set_TabIndex(2);
//
// button1
//
this.button1.set_Location(new System.Drawing.Point(14, 183));
this.button1.set_Name("button1");
this.button1.set_Size(new System.Drawing.Size(75, 23));
this.button1.set_TabIndex(3);
this.button1.set_Text("button1");
this.button1.set_UseVisualStyleBackColor(true);
this.button1.add_Click(new System.EventHandler(this.button1_Click));
//
// Form1
//
this.set_AutoScaleDimensions(new System.Drawing.SizeF(6F, 12F));
this.set_AutoScaleMode(System.Windows.Forms.AutoScaleMode.Font);
this.set_ClientSize(new System.Drawing.Size(284, 263));
this.get_Controls().Add(this.button1);
this.get_Controls().Add(this.textBox2);
this.get_Controls().Add(this.textBox1);
this.get_Controls().Add(this.label1);
this.set_Name("Form1");
this.set_Text("Form1");
this.ResumeLayout(false);
this.PerformLayout();

}
#endregion

private void button1_Click(Object sender, System.EventArgs e)
{

}
}

class Int { public static void main(String[] args ) {

int x;

x = textBox1 + textBox2 ;

System.out.println(x);

} }

0 new messages