wmaraci reklam

C# Windows Form Application - Hesap Makinası

6 Mesajlar 26.650 Okunma
wmaraci reklam

HeadHunter HeadHunter WM Aracı Kullanıcı
  • Üyelik 21.11.2010
  • Yaş/Cinsiyet 37 /
  • Meslek Bilgisayar Programcılıgı
  • Konum
  • Ad Soyad ** **
  • Mesajlar 2
  • Beğeniler 0 / 0
  • Ticaret 0, (%0)
Kendi yaptığım bir hesap makinası. Sizinle paylaşmak istedim.



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 Hesap_makinesi
{
public partial class Form1 : Form
{
int a, b;
string d;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "1";
}
else
{
textBox1.Text = textBox1.Text + "1";
}

}

private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "2";
}
else
{
textBox1.Text = textBox1.Text + "2";
}
}

private void button3_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "3";
}
else
{
textBox1.Text = textBox1.Text + "3";
}
}

private void button4_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "4";
}
else
{
textBox1.Text = textBox1.Text + "4";
}
}

private void button5_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "5";
}
else
{
textBox1.Text = textBox1.Text + "5";
}
}

private void button6_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "6";
}
else
{
textBox1.Text = textBox1.Text + "6";
}
}

private void button7_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "7";
}
else
{
textBox1.Text = textBox1.Text + "7";
}
}

private void button8_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "8";
}
else
{
textBox1.Text = textBox1.Text + "8";
}
}

private void button9_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "9";
}
else
{
textBox1.Text = textBox1.Text + "9";
}
}

private void button10_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Text = "0";
}
else
{
textBox1.Text = textBox1.Text + "0";
}
}

private void button11_Click(object sender, EventArgs e)
{
a = Convert.ToInt16(textBox1.Text);
d = "+";
textBox1.Text = "";
}

private void button12_Click(object sender, EventArgs e)
{
a = Convert.ToInt16(textBox1.Text);
d = "-";
textBox1.Text = "";
}

private void button13_Click(object sender, EventArgs e)
{
a = Convert.ToInt16(textBox1.Text);
d = "*";
textBox1.Text = "";
}

private void button14_Click(object sender, EventArgs e)
{
a = Convert.ToInt16(textBox1.Text);
d = "/";
textBox1.Text = "";
}

private void button16_Click(object sender, EventArgs e)
{
b = Convert.ToInt16(textBox1.Text);
if (d == "")
{

}


if (d == "+")
{
textBox1.Text = Convert.ToString(a + b);
}
if (d == "-")
{
textBox1.Text = Convert.ToString(a - b);
}
if (d == "*")
{
textBox1.Text = Convert.ToString(a * b);
}
if (d == "/")
{
textBox1.Text = Convert.ToString(a / b);
}
}

private void Form1_Load(object sender, EventArgs e)
{
d = "";
}

private void button15_Click(object sender, EventArgs e)
{
a = 0;
b = 0;
d = "";
textBox1.Text = "0";
}



}
}
 

 

SMM Panel, Sosyalyuvam, Bayilik Paneli, En Uygun Panel, Takipçi Paneli
reklam

47hkn47 47hkn47 WM Aracı Kullanıcı
  • Üyelik 11.01.2011
  • Yaş/Cinsiyet - / E
  • Meslek
  • Konum Ankara
  • Ad Soyad C** K**
  • Mesajlar 67
  • Beğeniler 10 / 26
  • Ticaret 0, (%0)
arkadaşım kodları kopyala yapıştır yaptım açmıyor...
hata veriyor...
 

 

occipital occipital Öğrenci-Blog Yazarlığı... Kullanıcı
  • Üyelik 03.12.2010
  • Yaş/Cinsiyet 27 / E
  • Meslek Öğrenci-Blog Yazarlığı...
  • Konum
  • Ad Soyad Ç** K**
  • Mesajlar 1194
  • Beğeniler 126 / 122
  • Ticaret 5, (%100)
Tabi hata verir :D
16 tane buton koy 1 tanede text box :D
 

 

pls06 pls06 WM Aracı Kullanıcı
  • Üyelik 16.01.2011
  • Yaş/Cinsiyet 36 / E
  • Meslek web tasarım
  • Konum Zonguldak
  • Ad Soyad B** S**
  • Mesajlar 459
  • Beğeniler 5 / 4
  • Ticaret 1, (%100)
C# yi yeni yeni öğrenen birisi olarak tebrik ederim güzel çalışma olmuş
 

 

wmaraci
wmaraci

saidyavuz saidyavuz WM Aracı Kullanıcı
  • Üyelik 26.11.2010
  • Yaş/Cinsiyet - /
  • Meslek Primary school teacher
  • Konum
  • Ad Soyad ** **
  • Mesajlar 394
  • Beğeniler 0 / 20
  • Ticaret 0, (%0)
kodda çok fazla analiz hatası var. form kısmını aşağıdaki şekilde deneyin tabi diğer dökümanları da formla birlikte görebilseydik çok daha iyi olurdu.


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 said
{
public partial class Form1 : Form
{
decimal sayi1, sayi2, sonuc;
string Islem;
int digit;
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}
private void yaz(string sayi)
{
if (TxtEkran.Text == "0.00")
{
digit = 1;
TxtEkran.Text = sayi.ToString();
}
else
{
digit = digit + 1;
TxtEkran.Text = TxtEkran.Text + sayi.ToString();
}
}

private void Btn0_Click(object sender, EventArgs e)
{
yaz("0");
}



private void Btn1_Click(object sender, EventArgs e)
{
yaz("1");
}

private void Btn3_Click(object sender, EventArgs e)
{
yaz("3");
}

private void Btn2_Click(object sender, EventArgs e)
{
yaz("2");
}

private void Btn4_Click(object sender, EventArgs e)
{
yaz("4");
}

private void Btn5_Click(object sender, EventArgs e)
{
yaz("5");
}

private void Btn6_Click(object sender, EventArgs e)
{
yaz("6");
}

private void Btn7_Click(object sender, EventArgs e)
{
yaz("7");
}

private void Btn8_Click(object sender, EventArgs e)
{
yaz("8");
}

private void Btn9_Click(object sender, EventArgs e)
{
yaz("9");
}

private void BtnC_Click(object sender, EventArgs e)
{
TxtEkran.Text = "0.00";
TxtIslem.Text = "";
digit = 0;
sonuc = 0;
sayi1 = 0.00m;
sayi2 = 0.00m;
}

private void BtnTopla_Click(object sender, EventArgs e)
{


topla();
}

private void BtnEsit_Click(object sender, EventArgs e)
{
switch (Islem)
{
case "+":
topla();
TxtIslem.Text = sonuc.ToString();
Islem = null;
sonuc = 0.00m;
break;
case "-":
Cikar();
TxtIslem.Text = sonuc.ToString();
Islem = null;
sonuc = 0.00m;
break;
case "/":
break;
case "*":
break;

}


}

private void Cikar()
{
Islem = "-";
if ((TxtEkran.Text != "0.00") && (Islem != null))
{
TxtIslem.Text = TxtIslem.Text + TxtEkran.Text + " - " + "\r" + "\n";

}
else
{
// sayi1 = Convert.ToDecimal(TxtIslem.Text);
TxtIslem.Text = TxtIslem.Text + " - " + "\r" + "\n";

}

if (sayi1 == 0.00m)
{
try
{
sayi1 = Convert.ToDecimal(TxtEkran.Text);
TxtEkran.Text = "0.00";


}
catch (Exception)
{

TxtEkran.Text = "0.00";
}

}
else if (sayi2 == 0.00m)
{
try
{
sayi2 = Convert.ToDecimal(TxtEkran.Text);
TxtEkran.Text = "0.00";
sonuc = sayi1 - sayi2;
sayi1 = sonuc;
sayi2 = 0.00m;
TxtEkran.Text = "0.00";
}
catch (Exception)
{

TxtEkran.Text = "0.00";
}


}






}

private void topla()
{
Islem = "+";
if ((TxtEkran.Text != "0.00") && (Islem != null) )
{
TxtIslem.Text = TxtIslem.Text + TxtEkran.Text + " + " + "\r" + "\n";

}
else
{
// sayi1 = Convert.ToDecimal(TxtIslem.Text);
TxtIslem.Text = TxtIslem.Text+ " + " + "\r" + "\n";

}

if (sayi1 == 0.00m)
{
try
{
sayi1 = Convert.ToDecimal(TxtEkran.Text);
TxtEkran.Text = "0.00";


}
catch (Exception)
{

TxtEkran.Text = "0.00";
}

}
else if (sayi2 == 0.00m)
{
try
{
sayi2 = Convert.ToDecimal(TxtEkran.Text);
TxtEkran.Text = "0.00";
sonuc = sayi1 + sayi2;
sayi1 = sonuc;
sayi2 = 0.00m;
TxtEkran.Text = "0.00";
}
catch (Exception)
{

TxtEkran.Text = "0.00";
}


}






}

private void BtnCikar_Click(object sender, EventArgs e)
{
Cikar();
}
}
}





// private void button11_Click(object sender, EventArgs e)
// {
// a = Convert.ToInt16(textBox1.Text);
// d = "+";
// textBox1.Text = "";
// }

// private void button12_Click(object sender, EventArgs e)
// {
// a = Convert.ToInt16(textBox1.Text);
// d = "-";
// textBox1.Text = "";
// }

// private void button13_Click(object sender, EventArgs e)
// {
// a = Convert.ToInt16(textBox1.Text);
// d = "*";
// textBox1.Text = "";
// }

// private void button14_Click(object sender, EventArgs e)
// {
// a = Convert.ToInt16(textBox1.Text);
// d = "/";
// textBox1.Text = "";
// }

// private void button16_Click(object sender, EventArgs e)
// {
// b = Convert.ToInt16(textBox1.Text);
// if (d == "")
// {

// }


// if (d == "+")
// {
// textBox1.Text = Convert.ToString(a + b);
// }
// if (d == "-")
// {
// textBox1.Text = Convert.ToString(a - b);
// }
// if (d == "*")
// {
// textBox1.Text = Convert.ToString(a * b);
// }
// if (d == "/")
// {
// textBox1.Text = Convert.ToString(a / b);
// }
// }

// private void Form1_Load(object sender, EventArgs e)
// {
// d = "";
// }

// private void button15_Click(object sender, EventArgs e)
// {
// a = 0;
// b = 0;
// d = "";
// textBox1.Text = "0";
// }



// }
//}





 

 

gandal33 gandal33 WM Aracı Kullanıcı
  • Üyelik 29.03.2011
  • Yaş/Cinsiyet 33 / E
  • Meslek Bilgisayar Mühendisi
  • Konum İstanbul Avrupa
  • Ad Soyad M** Y**
  • Mesajlar 33
  • Beğeniler 13 / 12
  • Ticaret 0, (%0)
başlangıç için güzel :D
 

 

wmaraci
Konuyu toplam 1 kişi okuyor. (0 kullanıcı ve 1 misafir)
Site Ayarları
  • Tema Seçeneği
  • Site Sesleri
  • Bildirimler
  • Özel Mesaj Al