Ciao,ho reato una calcolatrice tramite il compilatore visual studio 2010 e usando naturalmente .net 4.0.
Tutto ok ci ho messo tempo a risolvere certi problemi ma ci sono riuscito (tempo un giorno intero fino alle 2 di notte xd).I linguaggi che so sono il pascal,C++ e ora mi sto avicinando al c# per le form(ho 14 anni

).
Cqm... sto cercando di fare in tutti i modi ma niente keypress,keydown etc ma niente.In pratica vorrei fare che se per esempio da tastiera si preme + si deve premere e/o avere lo stesso effetto appunto del tasto + e la stessa cosa per i numeri etc.
Ecco il sorgente della form (‹‹The hĂckEr~pRo››™ sono io

):
Quote:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool plus = false;
bool meno = false;
bool moltiplica = false;
bool dividi = false;
bool uguale = false;
bool Cradice = false;
bool Pgreco = false;
private void primo_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "1";
}
private void checkuguale()
{
if (uguale || Cradice || Pgreco)
{
textBox1.Text = "";
uguale = false;
Cradice = false;
Pgreco = false;
}
}
private void secondo_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "2";
}
private void terzo_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "3";
}
private void quarto_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "4";
}
private void quinto_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "5";
}
private void sesto_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "6";
}
private void settimo_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "7";
}
private void ottavo_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "8";
}
private void nono_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "9";
}
private void BCancella_Click(object sender, EventArgs e)
{
plus = meno = moltiplica = dividi = uguale = false;
textBox1.Text = "";
textBox1.Tag = "";
}
private void zero_Click(object sender, EventArgs e)
{
checkuguale();
textBox1.Text = textBox1.Text + "0";
}
private void radice_Click(object sender, EventArgs e)
{
Cradice = true;
textBox1.Text = Convert.ToString(System.Math.Sqrt(Convert.ToDouble(textBox1.Text)));
}
private void BPunto_Click(object sender, EventArgs e)
{
checkuguale();
if (textBox1.Text != "")
{
textBox1.Text = textBox1.Text + ",";
}
}
private void BInfo_Click(object sender, EventArgs e)
{
MessageBox.Show(" Create by ‹‹The hĂckEr~pRo››™" + "\n" + " [email protected]" + "\n" + " V 1.0");
}
private void addizione_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
plus = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void sottrazioni_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
meno = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void moltiplicazioni_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
moltiplica = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void divisioni_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
dividi = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void BUguale_Click(object sender, EventArgs e)
{
uguale = true;
if (plus)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
if (meno)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) - Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
if (moltiplica)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
if (dividi)
{
decimal dec = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text);
textBox1.Text = dec.ToString();
}
}
private void BPluesmeno_Click(object sender, EventArgs e)
{
if (textBox1.Text.Contains("-"))
{
textBox1.Text = textBox1.Text.Remove(0, 1);
}
else
{
textBox1.Text = "-" + textBox1.Text;
}
}
private void BPiGreco_Click(object sender, EventArgs e)
{
Pgreco = true;
textBox1.Text = "3,14159265358979323846";
}
}
}
|