Aplikasi Mendeteksi Angka pada C#
INPUT
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication12
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void
button1_Click(object sender, EventArgs e)
{
String cas = textNIM.Text;
String angkatan = null;
String jurusan = null;
char[] a = cas.ToCharArray();
if (a[0] == '0'
&& a[1] == '9')
{
angkatan = "2009";
}
else if (a[0] == '1' && a[1] == '0')
{
angkatan = "2010";
}
else if (a[0] == '1' && a[1] == '1')
{
angkatan = "2011";
}
else if (a[0] == '1' && a[1] == '2')
{
angkatan = "2012";
}
else
{
angkatan = "Angakatan Belum
Terdeteksi";
}
if (a[3] == '1'
&& a[4] == '1')
{
jurusan = "Teknik Informatika";
}
else if (a[3] == '1' && a[4] == '2')
{
jurusan = "Sistem Informasi";
}
else
{
jurusan = "Jurusan Tidak
diketahui";
}
textJurusan.Text = jurusan;
textTahun.Text = angkatan;
textNomor.Text = "" + a[6]
+ a[7] + a[8] + a[9];
}
}
}
CODING CARA COPY, MOVING, DELETE PADA C#
APLIKASI COPY, MOVE & DELETE FILE PADA C#
INPUT
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void
button1_Click(object sender, EventArgs e)
{
string cari = "";
openFileDialog1.Filter = "All
Files(*.*)|*.*";
openFileDialog1.ShowDialog();
cari = openFileDialog1.FileName;
textBox1.Text = (cari);
}
private void
button2_Click(object sender, EventArgs e)
{
string simpan = "";
saveFileDialog1.Filter = "All
Files(*.*)|*.*";
saveFileDialog1.ShowDialog();
simpan = saveFileDialog1.FileName;
textBox2.Text = (simpan);
}
private void
button3_Click(object sender, EventArgs e)
{
MessageBox.Show("Press
OK to copy the file");
File.Copy(textBox1.Text, textBox2.Text);
}
private void
button4_Click(object sender, EventArgs e)
{
MessageBox.Show("Press
OK to move the file");
File.Move(textBox1.Text, textBox2.Text);
}
private void
button5_Click(object sender, EventArgs e)
{
MessageBox.Show("Press
OK to delete the file");
File.Delete(textBox1.Text);
}
}
}
Coding Menghitung Keliling Persegi Panjang pada C#
Aplikasi Menghitung Keliling Persegi Panjang pada C#
INPUT
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void
Form1_Load(object sender, EventArgs e)
{
}
private void
txttutup_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void
txtreset_Click(object sender, EventArgs e)
{
txtpanjang.Clear();
txtlebar.Clear();
txtkeliling.Clear();
txtpanjang.Focus();
errorProvider1.SetError(txtpanjang,
"");
errorProvider1.SetError(txtlebar, "");
errorProvider1.SetError(txtkeliling, "");
}
private void
txthitung_Click(object sender, EventArgs e)
{
if (txtpanjang.Text == "")
{
errorProvider1.SetError(txtpanjang, "isikan
nilai panjang!");
txtpanjang.Focus();
}
else if
(txtlebar.Text == "")
{
errorProvider1.SetError(txtlebar, "isikan
nilai lebar!");
txtlebar.Focus();
}
else
{
txtkeliling.Text = (2 * (int.Parse(txtpanjang.Text)
* int.Parse(txtlebar.Text))).ToString();
txtpanjang.Clear();
txtlebar.Clear();
errorProvider1.SetError(txtpanjang,
"");
errorProvider1.SetError(txtlebar, "");
}
}
}
}
Tidak ada komentar:
Posting Komentar