You are on page 1of 13

Nama : Ulfa Yuliana

Nim : 41816120092

Matkul : Pemrograman Visual DotNet

Tugas Pertemuan 5

1. Form Data Gaji Pegawai


 Tampilan Awal program :

 Sintak Gaji Pegawai :

Public Class Form1

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
ComboBox1.Items.Add("Laki-Laki")
ComboBox1.Items.Add("Perempuan")
End Sub

Private Sub btnhitung_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnhitung.Click
If txtgolongan.Text = "1" Then
txtgajipokok.Text = "1.000.000"
ElseIf txtgolongan.Text = "2" Then
txtgajipokok.Text = "3.000.000"
ElseIf txtgolongan.Text = "3" Then
txtgajipokok.Text = "5.000.000"
ElseIf txtgolongan.Text = "4" Then
txtgajipokok.Text = "7.500.000"
Else
txtgajipokok.Text = "0"
End If

If txtjmlhanak.Text = "1" Then


txtjmlhtunjangananak.Text = "200.000"
ElseIf txtjmlhanak.Text = "2" Then
txtjmlhtunjangananak.Text = "400.000"
ElseIf txtjmlhanak.Text = "3" Then
txtjmlhtunjangananak.Text = "600.000"

End If

txttnjganjbtan.Text = (10 / 100 * txtgajipokok.Text) * txtlamakerja.Text


txttotalgaji.Text = txtgajipokok.Text + txttnjganjbtan.Text +
txtjmlhtunjangananak.Text

End Sub

Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim Konfirmasi As String
Konfirmasi = MsgBox("Anda Yakin Ingin Keluar ?", vbQuestion +
vbYesNo, "Konfirmasi")
If Konfirmasi = vbYes Then
Close()
End If

End Sub
End Class
 Hasil Program :
 Hasil Program Jika Akan Keluar :

LATIHAN PERCABANGAN DI MODUL 5

1. If Then Else
 Tampilan Awal program :
 Sintak If Then Else :
Public Class Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
If TextBox1.Text = "ulfayln18" Then
MsgBox("Password Benar", MsgBoxStyle.Information, "Password")
Else
MsgBox("Password Salah", MsgBoxStyle.Information, "Password")
TextBox1.Clear()
End If
Me.Close()
End Sub

End Class

 Hasil Program :
2. If Then Else If
 Tampilan Awal program :

 Sintak If Then Else If :


Public Class Form3

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim nilai As Integer
nilai = CInt(TextBoxt1.Text)

If (nilai >= 85) Then


MsgBox("Nilai A")
ElseIf (nilai >= 75 And nilai < 85) Then
MsgBox("Nilai B")
ElseIf (nilai >= 65 And nilai < 75) Then
MsgBox("Nilai C")
ElseIf (nilai >= 50 And nilai < 65) Then
MsgBox("Nilai D")
Else
MsgBox("Nilai E")
End If
TextBoxt1.Clear()
End Sub

End Class

 Hasil Program :

3. Select Case
 Tampilan Awal program :

 Sintak Select Case :


Public Class Form4
Dim nilai As Integer
Dim mutu As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Konversi ke String'
nilai = CInt(TextBox1.Text)
Select nilai
Case 1 To 50
mutu = "E"
Case 51 To 60
mutu = "D"
Case 61 To 75
mutu = "C"
Case 76 To 85
mutu = "B"
Case 85 To 100
mutu = "A"
Case Else
mutu = "Maaf out of range ya mas /mbak bro"
End Select
MsgBox("nilai mutu Anda : " & mutu, MsgBoxStyle.Information, "Nilai")
TextBox1.Clear()
End Sub

End Class

 Hasil Program :
LATIHAN PERULANGAN DI MODUL 5

1. Pernyataan For..Do

 Tampilan Awal program :

 Sintak Pernyataan For..Do :

Public Class Form5

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim x As Integer
For x = 1 To 10
ListBox1.Items.Add(x)
Next x
End Sub
End Class

 Hasil Program :

2. While do
 Tampilan Awal program :
 Sintak While do :

Public Class Form6

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Dim x As Integer
x=1
While x <= 10
ListBox1.Items.Add(x)
x=x+1
End While
End Sub
End Class

 Hasil Program :
3. For Bersarang
 Tampilan Awal program :

 Sintak For Bersarang :


Public Class Form7

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Dim x, y As Integer
For x = 1 To 3
For y = 1 To 2
ListBox1.Items.Add(x & y)
Next y
Next x
End Sub
End Class
 Hasil Program :

Thanks You

You might also like