Shiny Flashy Green Matrix
Posted by : Aulia Ihza H - 0089 Monday, March 22, 2021

 

1.Persiapan

2.Program Hello World

    
Buka Visual Studio dan Klik Create A New Project


Cari Console, disini saya menggunakan Console App untuk .NET Core


Beri Nama Proyek dan Klik Create


Ketikkan Code seperti dibawah ini

using System;
namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

Hasil Demo


3.Program Currency Converter

Lakukan hal yang sama seperti tutorial diatas tapi kali ini pilih Windows Forms


Tampilan Awal Forms.

Toolbox memiliki atribut di sisi kiri yang siap di-drag.

Toolbox kanan bawah untuk mengatur properti
dari atribut yang ditarik seperti nama objek dan ukuran teks


Setelah beberapa atribut didrag 




Dan diganti propertinya seperti Common Box


Pada Nama Form.Designer.CS akan ada
Nama-nama Atribut yang siap dialokasikan pada Nama-Form.CS
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;


Berikut Isi Kode dari Nama-Form.cs
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 WindowsFormsTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Converter()
 
        {
            float input = (float)this.numericUpDown1.Value;
            float output = input;
            if (this.comboBox1.SelectedItem.ToString() == "IDR")
            {
                if (this.comboBox2.SelectedItem.ToString() == "JPY")
                {
                    output = (float)(0.0076 * input);
                }
                if (this.comboBox2.SelectedItem.ToString() == "USD")
                {
                    output = (float)(0.000069 * input);
                }
                if (this.comboBox2.SelectedItem.ToString() == "EUR")
                {
                    output = (float)(0.000058 * input);
                }
                if (this.comboBox2.SelectedItem.ToString() == "RS")
                {
                    output = (float)(0.0050 * input);
                } 
            }
            if (this.comboBox1.SelectedItem.ToString() == "USD")
            {
                if (this.comboBox2.SelectedItem.ToString() == "IDR")
                {
                    output = (float)(14392.45 * input);
                }
                if (this.comboBox2.SelectedItem.ToString() == "JPY")
                {
                    output = (float)(108.76 * input);
                }
                if (this.comboBox2.SelectedItem.ToString() == "EUR")
                {
                    output = (float)(0.84 * input);
                }
                if (this.comboBox2.SelectedItem.ToString() == "RS")
                {
                    output = (float)(72.37 * input);
                }
            }
            this.textBox1.Text = output.ToString("0.##");
        }
 
        private void Form1_Load(object senderEventArgs e)
        {
            this.comboBox1.SelectedItem = "IDR";
            this.comboBox2.SelectedItem = "USD";
        }
 
        private void label1_Click(object senderEventArgs e)
        {
 
        }
 
        private void label2_Click(object senderEventArgs e)
        {
 
        }
 
        private void label4_Click(object senderEventArgs e)
        {
 
        }
 
        private void label3_Click_1(object senderEventArgs e)
        {
 
        }
 
        private void button1_Click_1(object senderEventArgs e)
        {
            Converter();
        }
    }
}
 
Dan Demo kodenya 







Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © 2013 Ini Blogspot Aul - Shiroi - Powered by Blogger - Designed by Johanes Djogan -