Jeg får intet resultat.
det drejer sig om følgende kode:using System;
using System.Windows.Forms;
public class frmMain : Form
{
private Label label1;
private Label label2;
private TextBox txtOperand1;
private TextBox txtOperand2;
private TextBox txtResult;
private Button button2;
private Button btnCalc;
#region Windows Code
private void InitializeComponent()
{
this.btnCalc = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtOperand1 = new System.Windows.Forms.TextBox();
this.txtOperand2 = new System.Windows.Forms.TextBox();
this.txtResult = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnCalc
//
this.btnCalc.Location = new System.Drawing.Point(12, 85);
this.btnCalc.Name = "btnCalc";
this.btnCalc.Size = new System.Drawing.Size(76, 23);
this.btnCalc.TabIndex = 0;
this.btnCalc.Text = "Resultat";
this.btnCalc.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label1.Location = new System.Drawing.Point(12, 7);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 20);
this.label1.TabIndex = 1;
this.label1.Text = "label1";
//
// label2
//
this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label2.Location = new System.Drawing.Point(12, 33);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 20);
this.label2.TabIndex = 2;
this.label2.Text = "label2";
//
// txtOperand1
//
this.txtOperand1.Location = new System.Drawing.Point(82, 7);
this.txtOperand1.Name = "txtOperand1";
this.txtOperand1.Size = new System.Drawing.Size(100, 20);
this.txtOperand1.TabIndex = 3;
//
// txtOperand2
//
this.txtOperand2.Location = new System.Drawing.Point(82, 33);
this.txtOperand2.Name = "txtOperand2";
this.txtOperand2.Size = new System.Drawing.Size(100, 20);
this.txtOperand2.TabIndex = 4;
//
// txtResult
//
this.txtResult.Location = new System.Drawing.Point(12, 59);
this.txtResult.Name = "txtResult";
this.txtResult.ReadOnly = true;
this.txtResult.Size = new System.Drawing.Size(170, 20);
this.txtResult.TabIndex = 5;
//
// button2
//
this.button2.Location = new System.Drawing.Point(106, 85);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(76, 23);
this.button2.TabIndex = 6;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
//
// frmMain
//
this.ClientSize = new System.Drawing.Size(194, 113);
this.Controls.Add(this.button2);
this.Controls.Add(this.txtResult);
this.Controls.Add(this.txtOperand2);
this.Controls.Add(this.txtOperand1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnCalc);
this.Name = "frmMain";
this.Load += new System.EventHandler(this.frmMain_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
public frmMain()
{
InitializeComponent();
}
private void btnCalc_Click(object sender, EventArgs e)
{
bool flag;
int operand1;
int operand2;
int answer;
// Input Step
// Check first input...
flag = int.TryParse(txtOperand1.Text, out operand1);
if (flag == false)
{
MessageBox.Show("Enter a whole number", "Input Error");
txtOperand1.Focus();
return;
}
// Check second input...
flag = int.TryParse(txtOperand2.Text, out operand2);
if (flag == false)
{
MessageBox.Show("Enter a whole number", "Input Error");
txtOperand2.Focus();
return;
}
// Process Step
answer = operand1 / operand2;
// Display Step
txtResult.Text = operand1.ToString() + " divided by " +
operand2.ToString() +
" equals " + answer.ToString();
txtResult.Visible = true;
}
private void btnExit_Click(object sender, EventArgs e)
{
Close();
}
public static void Main()
{
frmMain main = new frmMain();
Application.Run(main);
}
private void frmMain_Load(object sender, EventArgs e)
{
}
}