示例#1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            klk         = new Kalkulator();
            klk.nama    = this.cmbOperasi.Text.ToLower();
            klk.operasi = string.Empty;
            klk.hasils  = 0;
            klk.a       = Double.Parse(this.txtNilaiA.Text);
            klk.b       = Double.Parse(this.txtNilaiB.Text);


            if (this.cmbOperasi.SelectedIndex == -1)
            {
                MessageBox.Show("Silahkan Pilih Dulu Operasinya!!!");
            }
            else if (this.cmbOperasi.SelectedIndex == 0)
            {
                klk.hasils  = klk.a + klk.b;
                klk.operasi = "+";
            }
            else if (this.cmbOperasi.SelectedIndex == 1)
            {
                klk.hasils  = klk.a - klk.b;
                klk.operasi = "-";
            }
            else if (this.cmbOperasi.SelectedIndex == 2)
            {
                klk.hasils  = klk.a * klk.b;
                klk.operasi = "*";
            }
            else if (this.cmbOperasi.SelectedIndex == 3)
            {
                klk.hasils  = klk.a / klk.b;
                klk.operasi = "/";
            }

            this.OnCreate(klk);
        }
示例#2
0
 private void FrmEntry_OnCreate(Kalkulator klk)
 {
     lstboxHasil.Items.Add("Hasil " + klk.nama + " " + klk.a + " " + klk.operasi + " " + klk.b + " " + "=" + " " + klk.hasils);
 }