Kleidemos
17-02-2003, 19:54
Ho questo cod:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace EuroConv
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class FrmPrinc : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtEuro;
private System.Windows.Forms.TextBox txtLire;
private System.Windows.Forms.Button btCalcola;
private System.Windows.Forms.ComboBox select;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public FrmPrinc()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtEuro = new System.Windows.Forms.TextBox();
this.txtLire = new System.Windows.Forms.TextBox();
this.btCalcola = new System.Windows.Forms.Button();
this.select = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// txtEuro
//
this.txtEuro.Location = new System.Drawing.Point(296, 8);
this.txtEuro.Name = "txtEuro";
this.txtEuro.Size = new System.Drawing.Size(144, 20);
this.txtEuro.TabIndex = 0;
this.txtEuro.Text = "";
//
// txtLire
//
this.txtLire.Location = new System.Drawing.Point(8, 8);
this.txtLire.Name = "txtLire";
this.txtLire.Size = new System.Drawing.Size(144, 20);
this.txtLire.TabIndex = 2;
this.txtLire.Text = "";
//
// btCalcola
//
this.btCalcola.Location = new System.Drawing.Point(184, 72);
this.btCalcola.Name = "btCalcola";
this.btCalcola.Size = new System.Drawing.Size(88, 24);
this.btCalcola.TabIndex = 1;
this.btCalcola.Text = "Calcola";
this.btCalcola.Click += new System.EventHandler(this.calcola_Click);
//
// select
//
this.select.Items.AddRange(new object[] {
"€ -> &",
"& -> €"});
this.select.Location = new System.Drawing.Point(184, 8);
this.select.Name = "select";
this.select.Size = new System.Drawing.Size(72, 21);
this.select.TabIndex = 3;
//
// FrmPrinc
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(448, 101);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.select,
this.btCalcola,
this.txtLire,
this.txtEuro});
this.Name = "FrmPrinc";
this.Text = "EuroConv";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new FrmPrinc());
}
private void calcola_Click(object sender, System.EventArgs e)
{
double lir = double.Parse(this.txtLire.Text);
double eur = double.Parse(this.txtEuro.Text);
double tot_lire, tot_euro;
int CAMBIO = 1936;
if (this.txtEuro.Text != " " && this.select.Items[0])
{
tot_euro = lir/CAMBIO;
this.txtEuro.Text = tot_euro.ToString();
}
if (this.txtLire.Text != " " && this.select.Items[1])
{
tot_lire = eur*CAMBIO;
this.txtLire.Text = tot_lire.ToString();
}
}
}
}
Ma mi da errore!
Come risolvo la clausala dell'if?
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace EuroConv
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class FrmPrinc : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtEuro;
private System.Windows.Forms.TextBox txtLire;
private System.Windows.Forms.Button btCalcola;
private System.Windows.Forms.ComboBox select;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public FrmPrinc()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtEuro = new System.Windows.Forms.TextBox();
this.txtLire = new System.Windows.Forms.TextBox();
this.btCalcola = new System.Windows.Forms.Button();
this.select = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// txtEuro
//
this.txtEuro.Location = new System.Drawing.Point(296, 8);
this.txtEuro.Name = "txtEuro";
this.txtEuro.Size = new System.Drawing.Size(144, 20);
this.txtEuro.TabIndex = 0;
this.txtEuro.Text = "";
//
// txtLire
//
this.txtLire.Location = new System.Drawing.Point(8, 8);
this.txtLire.Name = "txtLire";
this.txtLire.Size = new System.Drawing.Size(144, 20);
this.txtLire.TabIndex = 2;
this.txtLire.Text = "";
//
// btCalcola
//
this.btCalcola.Location = new System.Drawing.Point(184, 72);
this.btCalcola.Name = "btCalcola";
this.btCalcola.Size = new System.Drawing.Size(88, 24);
this.btCalcola.TabIndex = 1;
this.btCalcola.Text = "Calcola";
this.btCalcola.Click += new System.EventHandler(this.calcola_Click);
//
// select
//
this.select.Items.AddRange(new object[] {
"€ -> &",
"& -> €"});
this.select.Location = new System.Drawing.Point(184, 8);
this.select.Name = "select";
this.select.Size = new System.Drawing.Size(72, 21);
this.select.TabIndex = 3;
//
// FrmPrinc
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(448, 101);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.select,
this.btCalcola,
this.txtLire,
this.txtEuro});
this.Name = "FrmPrinc";
this.Text = "EuroConv";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new FrmPrinc());
}
private void calcola_Click(object sender, System.EventArgs e)
{
double lir = double.Parse(this.txtLire.Text);
double eur = double.Parse(this.txtEuro.Text);
double tot_lire, tot_euro;
int CAMBIO = 1936;
if (this.txtEuro.Text != " " && this.select.Items[0])
{
tot_euro = lir/CAMBIO;
this.txtEuro.Text = tot_euro.ToString();
}
if (this.txtLire.Text != " " && this.select.Items[1])
{
tot_lire = eur*CAMBIO;
this.txtLire.Text = tot_lire.ToString();
}
}
}
}
Ma mi da errore!
Come risolvo la clausala dell'if?