Tugas 3

Aplikasi Calculator #1 :

Kalkulator yang saya buat ini seperti kalkulator pada umumnya tapi di sini saya tidak membuat angka bantuan untuk di click di aplikasi desktopnya jika pengguna ingin menggunakan calculator ini dengan mengclick saja. Berikut cara pembuatan calculatornya

1. Create New Project



2. Pilih Windows Form App



3. Configure Project



4. Pilih versi .Net yang diinginkan kemudian click create


5. Membuat Tampilan Aplication



6. Source Code dari aplication ini sebagai berikut:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Calkulator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
LBLHasil.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Angka 1 dan Angka 2 Harus di isi terlebih dahulu");
}
else
{
int a, b, c;
a = int.Parse(this.textBox1.Text);
b = int.Parse(this.textBox2.Text);
c = a + b;
this.LBLHasil.Text = c.ToString();
}
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
LBLHasil.Text = "";
}
private void button2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Angka 1 dan Angka 2 Harus di isi terlebih dahulu");
}
else
{
int a, b, c;
a = int.Parse(this.textBox1.Text);
b = int.Parse(this.textBox2.Text);
c = a - b;
this.LBLHasil.Text = c.ToString();
}
}
private void button3_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Angka 1 dan Angka 2 Harus di isi terlebih dahulu");
}
else
{
int a, b, c;
a = int.Parse(this.textBox1.Text);
b = int.Parse(this.textBox2.Text);
c = a * b;
this.LBLHasil.Text = c.ToString();
}
}
private void button4_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Angka 1 dan Angka 2 Harus di isi terlebih dahulu");
}
else
{
int a, b, c;
a = int.Parse(this.textBox1.Text);
b = int.Parse(this.textBox2.Text);
c = a / b;
this.LBLHasil.Text = c.ToString();
}
}
}
}

7. Hasil



Comments

Popular Posts