Professional Documents
Culture Documents
TUGAS PERTEMUAN 6
KODE PROGRAM :
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Latihan3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bulan();
tahun();
}
private void bulan()
{
for (int i = 1; i <= 12; i++)
{
cboBulan.Items.Add(System.Globalization.DateTimeFormatInfo.CurrentInfo.GetMonthName(i));
cboBulan.SelectedIndex = 0;
}
}
private void tahun()
{
for (int i = 1940; i <= DateTime.Now.Year; i++)
{
cboTahun.Items.Add(i);
cboTahun.SelectedIndex = 0;
}
}
private void btnMulai_Click(object sender, EventArgs e)
{
txtNama.Clear();
txtBanyak.Clear();
txtBeban.Clear();
txtTotal.Clear();
txtNama.Focus();
}
private void btnKeluar_Click(object sender, EventArgs e)
{
this.Close();
}
private void txtNama_KeyPress(object sender, KeyPressEventArgs
e)
{
if (e.KeyChar == 13)
{
SendKeys.Send("{tab}");
}
}
private void cboBulan_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void cboTahun_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
SendKeys.Send("{tab}");
}
}
private void txtBanyak_KeyPress(object sender, KeyPressEventArgs
e)
{
if (e.KeyChar == 13)
{
SendKeys.Send("{tab}");
}
}
private void txtBeban_KeyPress(object sender, KeyPressEventArgs
e)
{
if (e.KeyChar == 13)
{
SendKeys.Send("{tab}");
}
}
private void total()
{
float banyak, beban, tot;
banyak = float.Parse(txtBanyak.Text.Trim() !=string.Empty ?
txtBanyak.Text.Trim() :"0");
beban = float.Parse(txtBeban.Text.Trim() != string.Empty ?
txtBeban.Text.Trim() : "0");
tot = banyak * beban;
txtTotal.Text = tot.ToString();
}
private void txtBanyak_TextChanged(object sender, EventArgs e)
{
total();
}
private void txtBeban_TextChanged(object sender, EventArgs e)
{
total();
}
HASIL RUNNING KODE PROGRAM :
TUGAS PERTEMUAN 4
KODE PROGRAM :
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 Tugas4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBila2_TextChanged(object sender, EventArgs e)
{
}
}
}
PERTAMBAHAN :
PENGURANGAN :
PERKALIAN :
PEMBAGIAN :
MODULUS :
TUGAS PERTEMUAN 3
2. Efek Underline
6. Font Style BoldItalic
Kode yang diberikan di Modul 2 Pemrograman Visual sedikit berbeda yang terletak pada bagian kode
programnya, selain itu semuanya sama. Contohnya :