Walo hanya latihan, tetap harus dikerjakan sebagai bahan pembelajaran meski belum sempurna ada beberapa program yang masih bingung :( , semoga mendapat pencerahan nanti. Amin
Kodingnya :
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim fibo(10) As Integer
fibo(0) = 1
fibo(1) = 1
For i = 2 To 9
fibo(i) = fibo(i - 1) + fibo(i - 2)
Next
For i = 0 To 9
ListBox1.Items.Add(fibo(i))
Next
End Sub
2. Menampilkan Bilangan Prima kurang dari 100 :
Kodingnya :
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim tanda(100) As String
Dim x, y As Integer
For x = 2 To 100
If tanda(x) <> "*" Then
ListBox1.Items.Add(x)
For y = 2 * x To 100
If (y Mod x = 0) Then
tanda(y) = "*"
End If
Next
End If
Next
End Sub
3. Mengambil Nilai dari CheckBox :
masih bingung :-(
4. Mengambil Nilai dari Radio Button :
Kodingnya :
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub rdpria_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles rdpria.CheckedChanged
If rdpria.Checked = True And rdkawin.Checked = True Then
TextBox1.Text = "Istri"
ElseIf rdwanita.Checked = True And rdkawin.Checked = True Then
TextBox1.Text = "Suami"
Else
TextBox1.Text = "-"
End If
End Sub
Private Sub rdwanita_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles rdwanita.CheckedChanged
If rdpria.Checked = True And rdkawin.Checked = True Then
TextBox1.Text = "Istri"
ElseIf rdwanita.Checked = True And rdkawin.Checked = True Then
TextBox1.Text = "Suami"
Else
TextBox1.Text = "-"
End If
End Sub
Private Sub rdkawin_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles rdkawin.CheckedChanged
If rdpria.Checked = True And rdkawin.Checked = True Then
TextBox1.Text = "Istri"
ElseIf rdwanita.Checked = True And rdkawin.Checked = True Then
TextBox1.Text = "Suami"
Else
TextBox1.Text = "-"
End If
End Sub
Private Sub rdtidakkawin_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles rdtidakkawin.CheckedChanged
If rdpria.Checked = True And rdkawin.Checked = True Then
TextBox1.Text = "Istri"
ElseIf rdwanita.Checked = True And rdkawin.Checked = True Then
TextBox1.Text = "Suami"
Else
TextBox1.Text = "-"
End If
End Sub
End Class
5. Mengambil Nilai dari ListBox :
Kodingnya :
Public Class Form1
Private Sub Button9_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button9.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button2.Click
Dim x As Integer
For x = 1 To 10
ListBox1.Items.Add(x)
Next
End Sub
Private Sub Button3_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button3.Click
ListBox2.Items.Add(ListBox1.SelectedItem)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button4.Click
Dim dipilih = (From i In ListBox1.SelectedItems).ToArray()
For Each SelectedItems In dipilih
ListBox2.Items.Add(SelectedItems)
Next
End Sub
Private Sub Button5_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button5.Click
Dim semua = (From i In ListBox1.Items).ToArray()
For Each Items In semua
ListBox2.Items.Add(Items)
Next
End Sub
Private Sub Button6_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button6.Click
ListBox2.Items.Remove(ListBox2.SelectedItem)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button7.Click
Dim dipilih = (From i In ListBox2.SelectedItems).ToArray()
For Each SelectedItems In dipilih
ListBox2.Items.Remove(SelectedItems)
Next
End Sub
Private Sub Button8_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button8.Click
ListBox2.Items.Clear()
End Sub
End Class