1. Membuat Kalkulator Sederhana
1.1. Membuat Project Window Form di Visual Studio
Klik new project, pilih Windows Forms App
1.2. Konfigurasi Project
1.3. Membuat Desain Form
Buat desain form dengan label, textbox dan button
1.4. Buat Fungsi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Kalkulator | |
{ | |
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("Masukkan Bilangan 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 button2_Click(object sender, EventArgs e) | |
{ | |
if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text)) | |
{ | |
MessageBox.Show("Masukkan Bilangan 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("Masukkan Bilangan 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("Masukkan Bilangan 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 = ""; | |
} | |
} | |
} | |
{"mode":"full","isActive":false} |
1.5 Menjalankan Program
2. Membuat Currency Converter
2.1. Membuat Project Window Form di Visual Studio
Klik new project, pilih Windows Forms App
2.2. Konfigurasi Project
2.3. Membuat Desain Form
Buat desain form dengan label, textbox dan button
2.4. Buat Fungsi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Converter | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
int i = int.Parse(this.textBox1.Text); | |
if ((string)comboBox1.SelectedItem == "Indonesia(IDR)" && (string)comboBox2.SelectedItem == "Amerika(USD)") | |
{ | |
double hasil; | |
hasil = i*0.00001; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Indonesia(IDR)" && (string)comboBox2.SelectedItem == "Korea(KRW)") | |
{ | |
double hasil; | |
hasil = i * 0.07694; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Indonesia(IDR)" && (string)comboBox2.SelectedItem == "Jepang(JPY)") | |
{ | |
double hasil; | |
hasil = i * 0.00766; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Amerika(USD)" && (string)comboBox2.SelectedItem == "Indonesia(IDR)") | |
{ | |
double hasil; | |
hasil = i * 14560; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Amerika(USD)" && (string)comboBox2.SelectedItem == "Korea(KRW)") | |
{ | |
double hasil; | |
hasil = i * 1130.200; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Amerika(USD)" && (string)comboBox2.SelectedItem == "Jepang(JPY)") | |
{ | |
double hasil; | |
hasil = i * 110.950; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Korea(KRW)" && (string)comboBox2.SelectedItem == "Indonesia(IDR)") | |
{ | |
double hasil; | |
hasil = i * 12.888; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Korea(KRW)" && (string)comboBox2.SelectedItem == "Amerika(USD)") | |
{ | |
double hasil; | |
hasil = i * 0.00088; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Korea(KRW)" && (string)comboBox2.SelectedItem == "Jepang(JPY)") | |
{ | |
double hasil; | |
hasil = i * 0.09793; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Jepang(JPY)" && (string)comboBox2.SelectedItem == "Indonesia(IDR)") | |
{ | |
double hasil; | |
hasil = i * 131.230; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Jepang(JPY)" && (string)comboBox2.SelectedItem == "Amerika(USD)") | |
{ | |
double hasil; | |
hasil = i * 0.009; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if ((string)comboBox1.SelectedItem == "Jepang(JPY)" && (string)comboBox2.SelectedItem == "Korea(KRW)") | |
{ | |
double hasil; | |
hasil = i * 10.186; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
else if (comboBox1.SelectedItem == comboBox2.SelectedItem) | |
{ | |
double hasil; | |
hasil = i; | |
lblResult.Text = hasil.ToString("0.00"); | |
} | |
} | |
} | |
} | |
{"mode":"full","isActive":false} |
2.5 Menjalankan Program
Source code :
Kalkulator
Kalkulator
Tidak ada komentar:
Posting Komentar