You are on page 1of 14

TUGAS PEMTOGRAMAN VISUAL

PERTEMUAN 3,4 & 6

NAMA : REHAN SAPUTRA


NPM : 207006516097
RUANG : R.02
DOSEN : WINARSIH,S.SI.,MMSI.

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();
}

private void Form1_Load(object sender, EventArgs e)


{

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 button1_Click(object sender, EventArgs e)


{
int bil1, bil2;
double hasil;
bil1 = int.Parse(textBila1.Text);
bil2 = int.Parse(textBila2.Text);
hasil = bil1 + bil2;
txtHsl.Text = System.Convert.ToString(hasil);
}

private void button2_Click(object sender, EventArgs e)


{
int bil1, bil2;
double hasil;
bil1 = int.Parse(textBila1.Text);
bil2 = int.Parse(textBila2.Text);
hasil = bil1 - bil2;
txtHsl.Text = System.Convert.ToString(hasil);
}

private void button3_Click(object sender, EventArgs e)


{
int bil1, bil2;
double hasil;
bil1 = int.Parse(textBila1.Text);
bil2 = int.Parse(textBila2.Text);
hasil = bil1 * bil2;
txtHsl.Text = System.Convert.ToString(hasil);
}

private void button4_Click(object sender, EventArgs e)


{
int bil1, bil2;
double hasil;
bil1 = int.Parse(textBila1.Text);
bil2 = int.Parse(textBila2.Text);
hasil = bil1 / bil2;
txtHsl.Text = System.Convert.ToString(hasil);
}

private void button5_Click(object sender, EventArgs e)


{
int bil1, bil2;
double hasil;
bil1 = int.Parse(textBila1.Text);
bil2 = int.Parse(textBila2.Text);
hasil = bil1 % bil2;
txtHsl.Text = System.Convert.ToString(hasil);
}

private void textBila1_TextChanged(object sender, EventArgs e)


{

}
private void textBila2_TextChanged(object sender, EventArgs e)
{

private void textHsl_TextChanged(object sender, EventArgs e)


{

}
}
}

PERTAMBAHAN :
PENGURANGAN :

PERKALIAN :

PEMBAGIAN :
MODULUS :
TUGAS PERTEMUAN 3

Tampilan Awal Visual Studio

Desain Tampilan Form


Kode Program

Public Class Form1


Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles
CheckBox1.CheckedChanged
lblFont.Font = New Font("Microsoft Sans Serif", 16,
FontStyle.Strikeout) End Sub

Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles


CheckBox2.CheckedChanged
lblFont.Font = New Font("Microsoft Sans Serif", 16,
FontStyle.Underline) End Sub

Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton1.CheckedChanged
lblFont.Font = New Font("Microsoft Sans Serif", 16, FontStyle.Regular)
End Sub

Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton2.CheckedChanged
lblFont.Font = New Font("Microsoft Sans Serif", 16,
FontStyle.Italic) End Sub

Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton3.CheckedChanged
lblFont.Font = New Font("Microsoft Sans Serif", 16,
FontStyle.Bold) End Sub

Private Sub RadioButton4_CheckedChanged(sender As Object, e As EventArgs) Handles


RadioButton4.CheckedChanged
lblFont.Font = New Font("Microsoft Sans Serif", 16, FontStyle.Bold,
FontStyle.Italic)
End Sub
End Class
Hasil
1. Efek StrikeOut 5. Font Style Bold

2. Efek Underline
6. Font Style BoldItalic

3. Font Style Regular

4. Font Style Italic


Analisis :

Kode yang diberikan di Modul 2 Pemrograman Visual sedikit berbeda yang terletak pada bagian kode
programnya, selain itu semuanya sama. Contohnya :

private void checkBox1_CheckedChanged(object sender, EventArgs e)

lblFont.Font = new Font("Microsoft Sans Serif", 16, FontStyle.Strikeout);

Sedangkan kode yang saya gunakan yaitu :

Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles


CheckBox1.CheckedChanged
lblFont.Font = New Font("Microsoft Sans Serif", 16,
FontStyle.Strikeout) End Sub

You might also like