未处理的“System.FormatException”类型的异常出现在 mscorlib.dll 中

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication1
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.TextBox textBox2;
  private System.Windows.Forms.TextBox textBox3;
  private System.Windows.Forms.TextBox textBox4;
  private System.Windows.Forms.Button button1;
  private System.Windows.Forms.TextBox textBox5;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.textBox1 = new System.Windows.Forms.TextBox();
   this.textBox2 = new System.Windows.Forms.TextBox();
   this.textBox3 = new System.Windows.Forms.TextBox();
   this.textBox4 = new System.Windows.Forms.TextBox();
   this.button1 = new System.Windows.Forms.Button();
   this.textBox5 = new System.Windows.Forms.TextBox();
   this.SuspendLayout();
   //
   // textBox1
   //
   this.textBox1.Location = new System.Drawing.Point(144, 48);
   this.textBox1.Name = "textBox1";
   this.textBox1.TabIndex = 0;
   this.textBox1.Text = "";
   //
   // textBox2
   //
   this.textBox2.Location = new System.Drawing.Point(312, 48);
   this.textBox2.Name = "textBox2";
   this.textBox2.TabIndex = 1;
   this.textBox2.Text = "";
   //
   // textBox3
   //
   this.textBox3.Location = new System.Drawing.Point(464, 48);
   this.textBox3.Name = "textBox3";
   this.textBox3.TabIndex = 2;
   this.textBox3.Text = "";
   //
   // textBox4
   //
   this.textBox4.Location = new System.Drawing.Point(136, 104);
   this.textBox4.Name = "textBox4";
   this.textBox4.TabIndex = 3;
   this.textBox4.Text = "";
   //
   // button1
   //
   this.button1.Location = new System.Drawing.Point(360, 104);
   this.button1.Name = "button1";
   this.button1.TabIndex = 4;
   this.button1.Text = "=";
   this.button1.Click += new System.EventHandler(this.button1_Click);
   //
   // textBox5
   //
   this.textBox5.Location = new System.Drawing.Point(488, 96);
   this.textBox5.Name = "textBox5";
   this.textBox5.TabIndex = 5;
   this.textBox5.Text = "";
   //
   // Form1
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(792, 266);
   this.Controls.Add(this.textBox5);
   this.Controls.Add(this.button1);
   this.Controls.Add(this.textBox4);
   this.Controls.Add(this.textBox3);
   this.Controls.Add(this.textBox2);
   this.Controls.Add(this.textBox1);
   this.Name = "Form1";
   this.Text = "Form1";
   this.Load += new System.EventHandler(this.Form1_Load);
   this.ResumeLayout(false);

  }
  #endregion

  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }

  private void Form1_Load(object sender, System.EventArgs e)
  {
  
  }

  private void button1_Click(object sender, System.EventArgs e)
  {
   int  a=int.Parse(this.textBox1.Text.ToString().Trim());
   int  b=int.Parse(this.textBox2.Text.ToString().Trim());
   int  c=int.Parse(this.textBox3.Text.ToString().Trim());
   int  d=int.Parse(this.textBox4.Text.ToString().Trim());
   int resutl=a+b+c+d;
   this.textBox5.Text=resutl.ToString();

 


//   string a=this.textBox1.Text.ToString().Trim();
//   string b=this.textBox2.Text.ToString().Trim();
//   string c=this.textBox3.Text.ToString().Trim();
//   string d=this.textBox4.Text.ToString().Trim();
//   string resutl=a+b+c+d;
//   this.textBox5.Text=resutl;

 

  }
 }
}
 

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页