Sabtu, 23 April 2011

Contoh Coding dengan Bahasa Pemrograman C# Bagi Pemula


using System;
using System.Windows.Forms;
using System.IO;
using System.Drawing;

class FormAndi : Form
{
Label l1    = new Label();
Label l2    = new Label();
Label l3    = new Label();
Label l4    = new Label();
Label l5    = new Label();
Label l6    = new Label();
Label l7    = new Label();
Label l8    = new Label();
Label l9    = new Label();
CheckBox c1 = new CheckBox();
CheckBox c2 = new CheckBox();
CheckBox c3 = new CheckBox();
CheckBox c4 = new CheckBox();
CheckBox c5 = new CheckBox();
CheckBox c6 = new CheckBox();
CheckBox c7 = new CheckBox();
CheckBox c8 = new CheckBox();
CheckBox c9 = new CheckBox();
CheckBox c10 = new CheckBox();
CheckBox c11 = new CheckBox();
CheckBox c12 = new CheckBox();
TextBox  t1 = new TextBox();
TextBox t2  = new TextBox();
TextBox t3  = new TextBox();
Button b1   = new Button();
Label l10   = new Label();

FormAndi()
{
Controls.Add(l1);
Controls.Add(l2);
Controls.Add(l3);
Controls.Add(l4);
Controls.Add(l5);
Controls.Add(l6);
Controls.Add(l7);
Controls.Add(l8);
Controls.Add(c1);
Controls.Add(c2);
Controls.Add(c3);
Controls.Add(c4);
Controls.Add(c5);
Controls.Add(c6);
Controls.Add(c7);
Controls.Add(c8);
Controls.Add(c9);
Controls.Add(c10);
Controls.Add(c11);
Controls.Add(c12);
Controls.Add(t1);
Controls.Add(t2);
Controls.Add(t3);
Controls.Add(b1);
Controls.Add(l9);
Controls.Add(l10);

WindowState = FormWindowState.Maximized;
Text        = "Aplikasi Rental VCD";
Icon        = new Icon("a.Ico");
Size          = new Size(500,500);
l1.Location   = new Point(30,10);
l1.Size       = new Size(350,40);
l1.Text       = "PROGRAM PENJUALAN RENTAL VCD";
l1.Font       = new Font("Berlin Sans FB Demi",13,FontStyle.Bold|FontStyle.Underline);
b1.Location  = new Point(10,500);
b1.Size      = new Size(80,30);
b1.Font      = new Font("Comic Sans MS",12,FontStyle.Bold);
b1.Text     = "KELUAR";

l2.Location = new Point(5,50);   
c1.Location = new Point(5,70);
c2.Location = new Point(5,90);
c3.Location = new Point(5,110);
t1.Location = new Point(5,200);
l6.Location = new Point(5,180);
l6.Text     = "Film Drama / Komedi";
l6.Font     = new Font("Comic Sans MS",10,FontStyle.Bold|FontStyle.Italic);
l6.Size     = new Size(180,20);
t1.Size     = new Size(180,140);
t1.Multiline = true;
l7.Location = new Point(200,180);
l7.Size     = new Size(80,20);
l7.Text     = "Film Action";
l7.Font     = new Font("Comic Sans MS",10,FontStyle.Bold|FontStyle.Italic);
t2.Location = new Point(200,200);
t2.Size     = new Size(180,140);
t2.Multiline = true;
l8.Location = new Point(410,180);
l8.Size     = new Size(80,20);
l8.Text     = "Film Horor";
l8.Font     = new Font("Comic Sans MS",10,FontStyle.Bold|FontStyle.Italic);
t3.Location = new Point(410,200);
t3.Size     = new Size(180,140);
t3.Multiline = true;
l2.Text     = "Jenis VCD";
c1.Text     = "Drama/Komedi";
c2.Text     = "Action";
c3.Text     = "Horor";

l3.Location = new Point(150,50);
c4.Location = new Point(150,70);
c5.Location = new Point(150,90);
c6.Location = new Point(150,110);
l3.Text     = "Bacground 1";
c4.Text     = "Merah";
c5.Text     = "Kuning";
c6.Text     = "Biru";

l4.Location = new Point(380,50);
c7.Location = new Point(380,70);
c8.Location = new Point(380,90);
c9.Location = new Point(380,110);
l4.Text     = "Bacground 2";
c7.Text     = "Coklat";
c8.Text     = "Orange";
c9.Text     = "Hijau";

l5.Location = new Point(650,50);
c10.Location = new Point(650,70);
c11.Location = new Point(650,90);
c12.Location = new Point(650,110);
l5.Text     = "Bacground 3";
c10.Text     = "Emas";
c11.Text     = "Merah Muda";
c12.Text     = "Hitam";

l9.Location = new Point(5,400);
l9.Size     = new Size(450,50);
l9.Text     = "Di Buat Oleh : Jhelvi Katiandagho Jurusan Sistem Komputer"+
                                      " Semester Empat.";
l9.Font     = new Font("Comic Sans MS",14,FontStyle.Bold);

l10.Location = new Point(680,10);
l10.Size     = new Size(150,30);
l10.Font     = new Font("Comic Sans MS",10,FontStyle.Bold);
l10.Text     = "Tgl : 12 Mei 2009";

c1.Click += new EventHandler(drama);
c2.Click += new EventHandler(action);
c3.Click += new EventHandler(horor);

c4.Click += new EventHandler(merah);
c5.Click += new EventHandler(kuning);
c6.Click += new EventHandler(biru);

c7.Click += new EventHandler(coklat);
c8.Click += new EventHandler(orange);
c9.Click += new EventHandler(hijau);

c10.Click+= new EventHandler(emas);
c11.Click += new EventHandler(merahmuda);
c12.Click += new EventHandler(hitam);
b1.Click  += new EventHandler(keluar);

}

void drama (object o,EventArgs e)
{
t1.Text = "Go 30th Year,,"+
                          "Cinderella Man,,"+
                          "Chasing Library";
}

void action (object o,EventArgs e)
{
t2.Text = "Shark Boy and Lava Girl,,"+
                          "Spy Kids,,"+
                          "Lord Of The Ring,,"+
                          "Start Wars,,"+           
                          "Matrix";
}
                         
void horor (object o,EventArgs e)
{
t3.Text = "Skull,,"+
                          "Species II,,"+
                          "Sunder Bolong,,"+
                          "Kuntil Anak,,"+
                          "Nyayian Sundel Bolong,,"+
                          "Hantu Campus STMIK";
}
/*Coding BackGround 1*/

void merah (object o,EventArgs e)
{
t1.BackColor = Color.Red;
}
void kuning (object o,EventArgs e)
{
t1.BackColor = Color.Yellow;
}
void biru (object o,EventArgs e)
{
t1.BackColor = Color.Blue;
}
/*Coding BackGround 2*/
void coklat (object o,EventArgs e)
{
t2.BackColor = Color.Brown;
}
void orange (object o,EventArgs e)
{
t2.BackColor = Color.Orange;
}
void hijau (object o,EventArgs e)
{
t2.BackColor = Color.Green;
}

/*Coding BackGround 3*/                        
void emas (object o,EventArgs e)
{
t3.BackColor = Color.Gold;
}
void merahmuda (object o,EventArgs e)
{
t3.BackColor = Color.Pink;
}
void hitam (object o,EventArgs e)
{
t3.BackColor = Color.Black;
}

/*coding keluar*/
void keluar(object o,EventArgs e)
{
MessageBox.Show("Anda Ingin Keluar,,,?");
Close();

}
[STAThread]
static void Main()
{
Application.Run(new FormAndi());
}}

 setelah barisan program diatas selesai ditulis pada notepad atau editor yang ada, langkah selanjutnya yaitu tinggal dijalankan. untuk menjalankannya disini saya menggunakan command promnt untuk menjalankan program yang ada...

0 komentar:

Posting Komentar