LAPORAN PRAKTIKUM PEMROGRAMAN VISUAL
MODUL 4
CONDITION
Untuk memenuhi tugas matakuliah Praktikum Pemrograman Visual
yang dibimbing oleh Bapak Wahyu Sakti Gunawan Irianto
Oleh :
ARIF NURNANTO
(120533430966)
FAKULTAS TEKNIK
JURUSAN TEKNIK ELEKTRO
PRODI S1 PENDIDIKAN TEKNIK INFORMATIKA
UNIVERSITAS NEGERI MALANG
Februari 2013
A. TUJUAN
Memahami bentuk-bentuk condition
Memiliki strategi dalam penggunaan condition
Mampu menyelesaikan kasus-kasus yang melibatkan condition
B. LATIHAN
1. Pernyataan “If-then-else”
Source Code :
Module Module1
Sub Main()
Dim intVal As Integer = -3
If (intVal < 0) Then
Console.WriteLine("Negatif")
Else
Console.WriteLine("Positif")
End If
Console.Read()
End Sub
End Module
|
Tampilan :
2. Pernyataan Ir-Then menggunakan form
Source Code :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "Nilai Akhir"
Label2.Text = "Keterangan :"
Label3.Text = "-"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ket As String = ""
If CDbl(TextBox1.Text) >= 55 Then
ket = "Lulus"
End If
Label3.Text = ket
End Sub
End Class
|
Tampilan :
3. If-else-Then menggunakan Form
- Sintaks Program
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "Nilai Akhir : "
Label2.Text = "Keterangan"
Label3.Text = "-"
Button1.Text = "Proses"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ket As String
If CDbl(TextBox1.Text) >= 55 Then
ket = "Lulus"
Else
ket = "Gagal"
End If
Label3.Text = ket
End Sub
End Class
|
- Tampilan Program
C. PRAKTIKUM
1. Buat aplikasi dengan tampilan seperti gambar di bawah ini:
Isi textbox hasil dengan jawaban true / false, misal jika nilai 1 < nilai 2 maka pada textbox Nilai1 < Nilai 2 ? : berisi jawaban True, sedangkan textbox lainnya berisi False.
Sintaks program
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "Nilai 1"
Label2.Text = "Nilai 2"
Label3.Text = "Nilai 1< Nilai 2"
Label4.Text = "Nilai 1> Nilai 2"
Label5.Text = "Nilai 1= Nilai 2"
Label6.Text = "HASIL"
Button1.Text = "Proses"
Button2.Text = "Cancel"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As String
If CDbl(TextBox1.Text) > CDbl(TextBox2.Text) Then
TextBox3.Text = "FALSE"
TextBox4.Text = "TRUE"
TextBox5.Text = "FALSE"
ElseIf CDbl(TextBox1.Text) < CDbl(TextBox2.Text) Then
TextBox3.Text = "TRUE"
TextBox4.Text = "FALSE"
TextBox5.Text = "FALSE"
ElseIf CDbl(TextBox1.Text) = CDbl(TextBox2.Text) Then
TextBox3.Text = "FALSE"
TextBox4.Text = "FALSE"
TextBox5.Text = "TRUE"
End If
End Sub
End Class
|
Tampilan Program :
- Keterangan :
Di sini saya memberi text pada label dengan menggunakan sintaks. Konsep dari program ini yaitu telah usir menginputkan nilai pertama dan kedua maka program akan mengidentifikasi nilai pertama lebih besar atau lebih kecil atau sama dengan. Jika pernyataan terebut tadi benar maka pernyataan yang benar akan bernilai TRUE. Karena melalui textbox maka nilai dikonversi terlebih dahulu dengan tipe data double dengan menggunakan CDbl lalu dibandingkan dengan nilai kedua yang sudah juga dikonversi menjadi tipe data double.
2. Buatlah aplikasi matematika sebagai berikut:
jika radio button diklik maka:
- Label1 akan berubah mengikuti perintah (misalnya radiobutton pembagian diklik maka tanda akan berubah menjadi “/”)
- TextBox hasil akan berubah mengikuti perintah (Textboxhasil tidak didapat melalui event klik pada button tetapi event check pada radiobutton)
- Sintaks program
- Public Class Form1
-
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- RadioButton1.Text = "Penjumlahan"
- RadioButton2.Text = "Pengurangan"
- RadioButton3.Text = "Perkalian"
- RadioButton4.Text = "Pembagian"
- RadioButton5.Text = "Pemangkatan"
- End Sub
-
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim a As Integer = CDbl(TextBox1.Text)
- Dim b As Integer = CDbl(TextBox2.Text)
- Dim c As Integer
- If RadioButton1.Checked Then
- c = a + b
- ElseIf RadioButton2.Checked Then
- c = a - b
- ElseIf RadioButton3.Checked Then
- c = a * b
- ElseIf RadioButton4.Checked Then
- c = a / b
- ElseIf RadioButton5.Checked Then
- c = a ^ b
- End If
- TextBox3.Text = c
- End Sub
-
- Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
- Label1.Text = "+"
- End Sub
-
- Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
- Label1.Text = "-"
- End Sub
-
- Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
- Label1.Text = "X"
- End Sub
-
- Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
- Label1.Text = "/"
- End Sub
-
- Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
- Label1.Text = "^"
- End Sub
- End Class
-
-
|
Tampilan Program :
- Keterangan
Pada program di atas nilai dari texbox dikonversi terlebih dahulu menjadi double. Pada textbox untuk hasil tidak dinisiallisasikan dengan variabel terlebih dahulu karena variabel c nanti digunakan untuk hasil dari aritmetika. Dan kemudian texbox3.text = hasil karena untuk menampilkan dari hasil aritmetika.
D. Tugas Rumah
1. Aplikasi Form Sederhana
Sintaks :
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As String = TextBox1.Text
ProgressBar1.Minimum = 1
ProgressBar1.Maximum = 5000
For b As Single = ProgressBar1.Minimum To ProgressBar1.Maximum Step 0.001
ProgressBar1.Value = b
Next
If TextBox1.Text = "" Then
MessageBox.Show("Maaf, Anda belum memasukkan pilihan." & vbLf & "Silahkan Masukkan Nama terlebih dahulu !")
ElseIf ComboBox1.Text = "--Jenis Kelamin--" Then
MessageBox.Show("Jenis kelamin belum anda pilih")
ElseIf CheckBox1.Checked = False Then
If CheckBox2.Checked = False Then
MessageBox.Show("Anda belum memilih punya anak atau tidak !")
End If
End If
If RadioButton1.Checked Then
If CheckBox1.Checked Then
If ComboBox1.Text = "Perempuan" Then
MessageBox.Show("Selamat " & a & vbLf & ", Anda adalah istri dan ibu yang baik..")
ElseIf ComboBox1.Text = "Laki-laki" Then
MessageBox.Show("Selamat " & a & vbLf & ", Anda adalah suami dan ayah yang baik..")
End If
ElseIf CheckBox2.Checked Then
If ComboBox1.Text = "Perempuan" Then
MessageBox.Show("Anda belum mempunyai anak bu")
ElseIf ComboBox1.Text = "Laki-laki" Then
MessageBox.Show("Anda belum mempunyai anak pak")
End If
End If
ElseIf RadioButton2.Checked Then
If ComboBox1.Text = "Perempuan" Then
MessageBox.Show("Anda belum menikah bu")
ElseIf ComboBox1.Text = "Laki-laki" Then
MessageBox.Show("Anda belum menikah pak.")
End If
End If
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
If TextBox1.Text = "" Then
RadioButton2.Checked = False
MessageBox.Show("Masukkan Nama Dulu !")
GroupBox2.Enabled = False
Else
GroupBox2.Enabled = False
End If
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
If TextBox1.Text = "" Then
RadioButton1.Checked = False
MessageBox.Show("Masukkan Nama Dulu !")
GroupBox2.Enabled = False
Else
GroupBox2.Enabled = True
Button2.Visible = True
End If
End Sub
Private Sub MulaiLagiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MulaiLagiToolStripMenuItem.Click
TextBox1.Clear()
GroupBox2.Enabled = False
RadioButton1.Checked = False
'RadioButton2.Checked = False
CheckBox2.Checked = False
CheckBox1.Checked = False
ComboBox1.Text = "--Jenis Kelamin--"
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label5.Left = Label5.Left + 1
If Label5.Left >= Me.Width - Label5.Width Then
Timer1.Enabled = False
Timer2.Enabled = True
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Label5.Left = Label5.Left - 1
If Label5.Left <= 0 Then
Timer1.Enabled = True
Timer2.Enabled = False
End If
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
Label6.Left = Label6.Left + 1
If Label6.Left >= Me.Width - Label6.Width Then
Timer3.Enabled = False
Timer4.Enabled = True
End If
End Sub
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
Label6.Left = Label6.Left - 1
If Label6.Left <= 0 Then
Timer3.Enabled = True
Timer4.Enabled = False
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
CheckBox2.Enabled = False
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
CheckBox1.Enabled = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
CheckBox1.Checked = False
CheckBox2.Enabled = True
CheckBox2.Checked = False
CheckBox1.Enabled = True
End Sub
Private Sub TentangProgramToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TentangProgramToolStripMenuItem.Click
Me.Visible = False
Form2.Show()
End Sub
Private Sub ContactToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContactToolStripMenuItem.Click
Me.Visible = False
Form3.Visible = True
End Sub
End Class
|
Tampilan :
Form 2 (Program > Tentang Program)
Form 3 (Program > Lihat Versi Program
Penjelasan :
Konsep dari program Ni adalah setelah usir menginputkan nama dan belum mengisi option selanjutnya maka akan muncul message Box peringatan untuk mengisi terlebih dahulu option selanjutnya. Dan jika di ulangi maka option punya Anka akan mengulang atau kosong.
Modul 4.2
1. Latihan 1
Sintaks
Module Module1
Sub Main()
Dim strIn As String
Console.Write("Ketik Sembarang huruf : ")
strIn = Console.ReadLine
Select Case strIn
Case "A"
Console.WriteLine("Huruf A")
Case "Q", "X"
Console.WriteLine("Quit/Exit")
Case Else
Console.WriteLine(strIn)
End Select
Console.Read()
End Sub
End Module
|
Tampilan :
2. Latihan 2
Sintaks
Module Module1
Sub Main()
Dim intVal As Integer = -1
If (intVal < 0) Then
Console.WriteLine("Negatif")
ElseIf (intVal = 0) Then
Console.WriteLine("Nol")
Else
Console.WriteLine("Positif")
End If
Console.Read()
End Sub
End Module
|
Tampilan :
3. Latihan 3
Sintaks
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bil As Integer = CInt(TextBox1.Text)
Select Case bil
Case 1
MsgBox("Bilangan 1")
Case 2 To 5
MsgBox("Bilangan 2 sampai 5")
Case 6, 7, 8
MsgBox("Bilangan 6, 7, atau 8")
Case Is <= 1
MsgBox("Bilangan lebih kecil dari 1")
Case Else
MsgBox("Bilangan selain antara 1 sampai 8")
End Select
End Sub
End Class
|
Tampilan :
4. Latihan 4
Sintaks :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Text = "Pilih NIS"
ComboBox1.Items.Add("1101")
ComboBox1.Items.Add("1102")
ComboBox1.Items.Add("1103")
ComboBox1.Items.Add("1104")
TextBox1.Text = "- - - - - - - -"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nama As String
Dim NIS As String = ComboBox1.Text
nama = IIf(NIS = "1101", "Adi", IIf(NIS = "1102", "Sari", IIf(NIS = "1103", "Rudi", IIf(NIS = "1104", "Kamal", "Judika"))))
TextBox1.Text = nama
End Sub
End Class
|
Tampilan :
TUGAS PRAKTIKUM
1. Buatlah program yang mengambil hari ke berapa dari obyek ComboBox, yang bertujuan untuk menampilkan nama hari pada textbox. Proses akan dikerjakan setelah button di klik. Gunakan fungsi IIF dalam membuat program ini. Minimal tampilannya sebagai berikut!
Sintaks
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nm_hr As String
Dim h As String = ComboBox1.Text
nm_hr = IIf(h = "", "Tidak ada pilihan hari", IIf(h = "1", "Senin", IIf(h = "2", "Selasa", IIf(h = "3", "Rabu", IIf(h = "4", "Kamis", IIf(h = "5", "Jumat", IIf(h = "6", "Sabtu", "Minggu")))))))
TextBox1.Text = nm_hr
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add(1)
ComboBox1.Items.Add(2)
ComboBox1.Items.Add(3)
ComboBox1.Items.Add(4)
ComboBox1.Items.Add(5)
ComboBox1.Items.Add(6)
ComboBox1.Items.Add(7)
End Sub
End Class
|
Tampilan :
Ketrangan :
Konsep dari program ini adalah jika kita memilih hari ke berapa maka nama hari akan memunculkan nama hari sesuai urutan hari. Di sini digunakan kondisi Iis untuk pengkondisian nilai yang dimasukkan.
2. Buatlah program untuk menentukan Kode_MK dari Nama_MK yang telah dipilih, misal : bila praktikum VB yang diklik maka akan keluar kode_MK di textbox yang telah disediakan! Gunakan fungsi select-case dalam membuat program ini dan tulis nama MK sebanyak- banyaknya!
Sintaks :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.Add("Sistem Informasi")
ListBox1.Items.Add("ASD")
ListBox1.Items.Add("Digital dan Mikroprosesor")
ListBox1.Items.Add("Sistem Operasi")
ListBox1.Items.Add("KDJK")
ListBox1.Items.Add("PBO")
Label1.Text = "Nama : "
Label2.Text = "Mata Kuliah :"
Label3.Text = "Kode MK"
Label4.Text = "Nama Dosen"
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Select Case ListBox1.SelectedIndex
Case 0
TextBox2.Text = "PTI001"
TextBox3.Text = "Pak Didik"
Case 1
TextBox2.Text = "PTI002"
TextBox3.Text = "Pak Didik"
Case 2
TextBox2.Text = "PTI003"
TextBox3.Text = "Pak Made"
Case 3
TextBox2.Text = "PTI004"
TextBox3.Text = "Bu Triyana"
Case 4
TextBox2.Text = "PTI005"
TextBox3.Text = "Pak Muladi"
Case 5
TextBox2.Text = "PTI006"
TextBox3.Text = "Pak Heru"
End Select
End Sub
End Class
|
Tampilan :
Keterangan :
Konsep dari program ini adalah jika kita memilih mata kuliah maka kode mi dan nama depan dosen yang mengajar akan muncul.jadi Chase yang digunakan adalah listbox.selectedindex.
E. TUGAS RUMAH
1. F
Sintaks
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton1.Checked Then
Dim a As String = TextBox1.Text
Select Case a
Case "selamat pagi"
ListBox1.Items.Add("Good Morning")
Case "selamat siang"
ListBox1.Items.Add("Good Afternoon")
Case "selamat Malam"
ListBox1.Items.Add("Good evening")
Case "makan pagi"
ListBox1.Items.Add("Breakfast")
Case "makan siang"
ListBox1.Items.Add("Launch")
Case "makan malam"
ListBox1.Items.Add("Dinner")
Case "selamat tidur"
ListBox1.Items.Add("Good Night")
Case "semangat"
ListBox1.Items.Add("Spirit")
Case Else
MessageBox.Show("Maaf input yang anda masukkan mungkin berupa angka atau kosa kata yang anda masukkan tidak ada pada index atau database kami, coba teliti dan ulangi kembali !", "Aduh..", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Select
ElseIf RadioButton2.Checked Then
Dim b As String = TextBox1.Text
Select Case b
Case "good morning"
ListBox1.Items.Add("Selamat pagi")
Case "good afternoon"
ListBox1.Items.Add("Selamat siang")
Case "good evening"
ListBox1.Items.Add("Selamat Malam")
Case "breakfast"
ListBox1.Items.Add("Makan pagi")
Case "launch"
ListBox1.Items.Add("Makan Siang")
Case "dinner"
ListBox1.Items.Add("makan malam")
Case "good Night"
ListBox1.Items.Add("selamat tidur")
Case "spirit"
ListBox1.Items.Add("Semangat")
Case Else
MessageBox.Show("Maaf input yang anda masukkan mungkin berupa angka atau kosa kata yang anda masukkan tidak ada pada index atau database kami, coba teliti dan ulangi kembali !", "Aduh..", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Select
Else
MessageBox.Show("Maaf anda belum memilih pilihan terjemahan !!", "Aduh..", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Hide()
Form2.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label4.Text = "By : Arif Nurnanto_120533430966"
Me.Text = "Tugas Rumah_Modul 4.2"
Label1.Text = "Masukkan >"
Label2.Text = "Terjemahan"
Label3.TextAlign = ContentAlignment.MiddleCenter
Label3.Text = "Kamus Sederhana"
ListBox1.Items.Add("")
Button1.Text = "Terjemahkan"
Button2.Text = "Lihat Index"
Button3.Text = "Exit"
GroupBox1.Text = "Pilihan Terjemahan"
RadioButton1.Text = "Indonesia - Inggris"
RadioButton2.Text = "Inggris - Indonesia"
End Sub
End Class
|
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "Indonesia"
Label2.Text = "Inggris"
ListBox1.Items.Add("selamat pagi")
ListBox1.Items.Add("selamat siang")
ListBox1.Items.Add("selamat malam")
ListBox1.Items.Add("makan pagi")
ListBox1.Items.Add("makan siang")
ListBox1.Items.Add("makan malam")
ListBox1.Items.Add("semangat")
ListBox2.Items.Add("good morning")
ListBox2.Items.Add("good afternoon")
ListBox2.Items.Add("good evening")
ListBox2.Items.Add("good night")
ListBox2.Items.Add("breakfast")
ListBox2.Items.Add("launch")
ListBox2.Items.Add("dinner")
ListBox2.Items.Add("spirit")
Button1.Text = "Kambali"
Me.Text = "Index / Database"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Form1.Show()
End Sub
End Class
|
Tampilan :
Keterangan :
Program akan menerjemahkan teks yang dimasukkan sesuai dengan index yang ada di Sintak atau yang sudah ditentukan saja. Untuk melihat apa saja yang bisa diterjemahkan maka bisa di lihat di index dengan cara klik index.
2. Bu
Sintaks
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.RadioButton1 = New System.Windows.Forms.RadioButton()
Me.RadioButton2 = New System.Windows.Forms.RadioButton()
Me.RadioButton3 = New System.Windows.Forms.RadioButton()
Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label7 = New System.Windows.Forms.Label()
Me.Label8 = New System.Windows.Forms.Label()
Me.Button2 = New System.Windows.Forms.Button()
Me.TableLayoutPanel1.SuspendLayout()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(27, 129)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Tampilkan"
Me.Button1.UseVisualStyleBackColor = True
'
'RadioButton1
'
Me.RadioButton1.AutoSize = True
Me.RadioButton1.Location = New System.Drawing.Point(12, 55)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(92, 17)
Me.RadioButton1.TabIndex = 1
Me.RadioButton1.TabStop = True
Me.RadioButton1.Text = "Malang - Blitar"
Me.RadioButton1.UseVisualStyleBackColor = True
'
'RadioButton2
'
Me.RadioButton2.AutoSize = True
Me.RadioButton2.Location = New System.Drawing.Point(12, 78)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.Size = New System.Drawing.Size(114, 17)
Me.RadioButton2.TabIndex = 2
Me.RadioButton2.TabStop = True
Me.RadioButton2.Text = "Malang - Surabaya"
Me.RadioButton2.UseVisualStyleBackColor = True
'
'RadioButton3
'
Me.RadioButton3.AutoSize = True
Me.RadioButton3.Location = New System.Drawing.Point(12, 101)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.Size = New System.Drawing.Size(129, 17)
Me.RadioButton3.TabIndex = 3
Me.RadioButton3.TabStop = True
Me.RadioButton3.Text = "Malang- Tulungagung"
Me.RadioButton3.UseVisualStyleBackColor = True
'
'TableLayoutPanel1
'
Me.TableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.InsetDouble
Me.TableLayoutPanel1.ColumnCount = 2
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 49.5!))
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.5!))
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.Controls.Add(Me.Label3, 0, 1)
Me.TableLayoutPanel1.Controls.Add(Me.Label4, 1, 1)
Me.TableLayoutPanel1.Controls.Add(Me.Label5, 0, 2)
Me.TableLayoutPanel1.Controls.Add(Me.Label6, 1, 2)
Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 0)
Me.TableLayoutPanel1.Controls.Add(Me.Label2, 1, 0)
Me.TableLayoutPanel1.Location = New System.Drawing.Point(164, 55)
Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
Me.TableLayoutPanel1.RowCount = 3
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 45.09804!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 54.90196!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35.0!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.Size = New System.Drawing.Size(191, 97)
Me.TableLayoutPanel1.TabIndex = 4
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(6, 28)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(84, 27)
Me.Label3.TabIndex = 2
Me.Label3.Text = "-"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(99, 28)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(86, 27)
Me.Label4.TabIndex = 3
Me.Label4.Text = "-"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(6, 58)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(84, 36)
Me.Label5.TabIndex = 4
Me.Label5.Text = "-"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(99, 58)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(86, 36)
Me.Label6.TabIndex = 5
Me.Label6.Text = "-"
Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(6, 3)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(84, 22)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Siang"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(99, 3)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(86, 22)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Malam"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label7
'
Me.Label7.Location = New System.Drawing.Point(12, 0)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(342, 23)
Me.Label7.TabIndex = 5
Me.Label7.Text = "Jadwal Kereta Malang ke Sekitarnya"
Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label8
'
Me.Label8.Location = New System.Drawing.Point(15, 23)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(339, 23)
Me.Label8.TabIndex = 6
Me.Label8.Text = "By : Arif Nurnanto_120533430966_PTI 12 off A"
Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(108, 129)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(50, 23)
Me.Button2.TabIndex = 7
Me.Button2.Text = "Keluar"
Me.Button2.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(367, 162)
Me.ControlBox = False
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.TableLayoutPanel1)
Me.Controls.Add(Me.RadioButton3)
Me.Controls.Add(Me.RadioButton2)
Me.Controls.Add(Me.RadioButton1)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Tugas Rumah 2_Modul 4.2"
Me.TableLayoutPanel1.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Dim a As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Select Case a
Case 1
Label3.Text = "14.09"
Label5.Text = "15.15"
Label4.Text = "17.10"
Label6.Text = "-"
Case 2
Label3.Text = "13.30"
Label5.Text = "14.45"
Label4.Text = "17.10"
Label6.Text = "19.10"
Case 3
Label3.Text = "14.09"
Label5.Text = "15.15"
Label4.Text = "-"
Label6.Text = "-"
End Select
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
a = 1
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
a = 2
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
a = 3
End Sub
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
|
Tampilan :
Keterangan:
Masing-masing Radio Buton akan memberikan variabel pada sebuah variabel a, di mana variabel a nanti akan digunakan sebagai select case.
F. ESIMPULAN
Pada kondisi di Visual basi ada berbagai kondisi, antara lain If, Iif, Ir-else-then, Select Case. Masing-masing mempunyai peranan yang berbeda, Contohnya pada select case digunakan untuk menjalankan satu blok perintah yang jumlahnya banyak atau bertingkat-tingkat. Untuk Ir digunakan untuk beberapa kondisi.
G. DAFTAR PUSTAKA
o Modul Praktikum
o Google
o Nantslight.blogspot.com
0 comments:
Post a Comment