You are on page 1of 11

Nama : Ulfa Yuliana

Nim : 41816120092

Matkul : Pemrograman Visual DotNet

Tugas 2

 Latihan Memasang control pada form DI Modul 2


1. Tampilan Program From1 – Nama Anda

 Sintak program From Nama :

Public Class Form1

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


System.EventArgs) Handles Button1.Click
Label2.Text = TextBox1.Text
End Sub

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


System.EventArgs) Handles Button2.Click
TextBox1.Text = " "
Label2.Text = " "
End Sub

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


System.EventArgs) Handles TextBox1.TextChanged

End Sub
End Class
 Hasil program :
 Ketika dimasukkan Nama dan Klik button OK

 Ketika diklik button Batal , maka isi textbox dan label hasil akan seperti
dibawah ini :
2. Tampilan Program ListBox

 Sintak Program :

Public Class ListBox

Shared Item As Object

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


System.EventArgs) Handles MyBase.Load
Latihan1.ListBox.Item.Add("Satu")
ListBox.Item.Add("Dua")
ListBox.Item.Add("Tiga")
End Sub

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


As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Label1.Text = ListBox1.SelectedItem.ToString
End Sub
End Class

 Hasil Program :
TUGAS 1 & 2
1. ComboBox
 Tampilan Awal

 Sintak Program :

Public Class ComboBox

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


As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox1.Items.Add("Satu")
ComboBox1.Items.Add("Dua")
ComboBox1.Items.Add("Tiga")
ComboBox1.Items.Add("Empat")
ComboBox1.Items.Add("Lima")
TextBox1.Text = ComboBox1.Text
End Sub
End Class
 Hasil Program :

2. Visual Basic, Java, Delphi 2010 – CheckBox (Form5)


 Tampilan Awal Program

 Sintak Program :

Public Class From5

Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs)

End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CheckBox1.CheckedChanged
Dim hasil As String
hasil = ""
If CheckBox1.Checked = True Then
hasil &= CheckBox1.Text
hasil &= ""

End If
If CheckBox2.Checked = True Then
hasil &= CheckBox2.Text
hasil &= ""

End If
If CheckBox3.Checked = True Then
hasil &= CheckBox3.Text
hasil &= ""
End If

If hasil <> Nothing Then


MsgBox("Bahasa Pilihan Anda: " + hasil + vbLf + " & " + "Terima Kasih")
End If
End Sub
End Class
 Hasil Program :

3. Radio Button – Form 6


 Tampilan Awal Program

 Sintak Program :

Public Class Form6

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


System.EventArgs) Handles Button1.Click
If RadioButton1.Checked Then
MsgBox("Anda Memilih : " & RadioButton1.Text)
End If
If RadioButton2.Checked Then
MsgBox("Anda Memilih : " & RadioButton2.Text)
End If
If RadioButton3.Checked Then
MsgBox("Anda Memilih : " & RadioButton3.Text)
End If
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click

End Sub
End Class

 Hasil Program:
4. Picture Box
 Tampilan Awal Program

 Sintak Program :

Public Class pictureBox

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
With ComboBox1
.Items.Add("Normal")
.Items.Add("StretchImage")
.Items.Add("AutoSize")
.Items.Add("CenterImage")
.Items.Add("Zoom")
.SelectedIndex = 0
.DropDownStyle = ComboBoxStyle.DropDownList
End With
End Sub

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


As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
PictureBox1.SizeMode = ComboBox1.SelectedIndex
End Sub

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


System.EventArgs)

End Sub

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


System.EventArgs) Handles PictureBox1.Click

End Sub
End Class
 Hasil Program :

- THANK YOU -

You might also like