look at me

SELAMAT DATANG MAS, MBAK, OM, TANTE, PAKDHE,BUDHE DAN SEMUANYA

Minggu, 04 November 2012

Tugas 4 (Fibronanci, Prima, Check Box, Radio Button, List Box)




Karena keterbataan waktu unk menjelaskan maka langsung saja berikut screenshoot beserta kode sumberya

  • Bilangan Fibronanci

Public Class Form1

    Private Sub Bt_Mulai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Mulai.Click
        Dim Fibro(10) As Integer
        Dim i, j As Integer

        Fibro(0) = 1
        Fibro(1) = 1

        For i = 2 To 10
            Fibro(i) = Fibro(i - 1) + Fibro(i - 2)
        Next

        For j = 0 To 10
            Lb_1.Items.Add(Fibro(j))
        Next
    End Sub
End Class

  • Bilangan Prima
 



 Public Class Form1

    Private Sub Bt_Mulai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Mulai.Click
        Dim Tanda(100) As String
        Dim i, j As Integer

        For i = 2 To 100
            If Tanda(i) <> "*" Then
                Lb_1.Items.Add(i)
                For j = 2 * i To 100 Step i
                    Tanda(j) = "*"
                Next
            End If
        Next
    End Sub
End Class
Public Class Form1

    Private Sub Bt_Mulai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Mulai.Click
        Dim Tanda(100) As String
        Dim i, j As Integer

        For i = 2 To 100
            If Tanda(i) <> "*" Then
                Lb_1.Items.Add(i)
                For j = 2 * i To 100 Step i
                    Tanda(j) = "*"
                Next
            End If
        Next
    End Sub
End Class


  • Check Box






Public Class Form1

   
    Private Sub Bt_Tutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Tutup.Click
        End
    End Sub

    Private Sub Cb_1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cb_1.CheckedChanged, Cb_2.CheckedChanged, Cb_3.CheckedChanged, Cb_4.CheckedChanged, Cb_5.CheckedChanged, Cb_6.CheckedChanged
        Dim Control As Windows.Forms.CheckBox
        Dim Kalimat As String = "Kemampuan bahasa Anda adalah "
        Txt_Bahasa.Text = ""

        For Each Control In Me.Gb_1.Controls
            If Control.Checked = True Then
                Kalimat &= Control.Text & ", "
                Txt_Bahasa.Text = Kalimat.Substring(0, Kalimat.Length - 2)
            End If

        Next
    End Sub
End Class


  • Radio Button



Public Class Form1

    Private Sub Bt_Tutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Tutup.Click
        End

    End Sub

    Private Sub Rb_Laki_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rb_Laki.CheckedChanged, Rb_Perempuan.CheckedChanged, Rb_Belum.CheckedChanged, Rb_Kawin.CheckedChanged
        If Rb_Laki.Checked = True Then
            If Rb_Kawin.Checked = True Then
                Txt_Pasangan.Text = "Istri"
            Else
                Txt_Pasangan.Text = ""
            End If
        Else
            If Rb_Kawin.Checked = True Then
                Txt_Pasangan.Text = "Suami"
            Else
                Txt_Pasangan.Text = ""
            End If
        End If
    End Sub
End Class

  • List Box




Public Class Form1

    Private Sub Bt_Tutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Tutup.Click
        End

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Lb_1.SelectionMode = SelectionMode.MultiExtended
        Lb_2.SelectionMode = SelectionMode.MultiExtended
        Bt_Satu.Enabled = False
        Bt_Beberapa.Enabled = False
        Bt_Smua.Enabled = False
        Bt_Hapus_Satu.Enabled = False
        Bt_Hapus_Beberapa.Enabled = False
        Bt_Hapus_Semua.Enabled = False
    End Sub

    Private Sub Bt_Masuk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Masuk.Click
        Bt_Satu.Enabled = True
        Bt_Beberapa.Enabled = True
        Bt_Smua.Enabled = True
        Bt_Hapus_Satu.Enabled = True
        Bt_Hapus_Beberapa.Enabled = True
        Bt_Hapus_Semua.Enabled = True

        If Txt_Input.Text = "" Then
            Lb_1.Items.Add("Kosong")
            Txt_Input.Focus()
        Else
            Lb_1.Items.Add(Txt_Input.Text)
            Txt_Input.Focus()
        End If
    End Sub

    Private Sub Bt_1_10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_1_10.Click
        Bt_Satu.Enabled = True
        Bt_Beberapa.Enabled = True
        Bt_Smua.Enabled = True
        Bt_Hapus_Satu.Enabled = True
        Bt_Hapus_Beberapa.Enabled = True
        Bt_Hapus_Semua.Enabled = True
        Dim i As Integer

        For i = 1 To 10
            Lb_1.Items.Add(i)
        Next

    End Sub

    Private Sub Bt_Satu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Satu.Click
        Lb_1.SelectionMode = SelectionMode.One
        Try
            Lb_2.Items.Add(Lb_1.SelectedItem)
        Catch ex As Exception

        End Try

    End Sub

    Private Sub Bt_Smua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Smua.Click
        Lb_1.SelectionMode = SelectionMode.MultiExtended

        Dim Jumlah As Integer = Lb_1.Items.Count

        For i = 0 To Jumlah - 1
            Lb_2.Items.Add(Lb_1.Items(i))
        Next
    End Sub

    Private Sub Bt_Hapus_Semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Semua.Click
        Lb_2.Items.Clear()
    End Sub

    Private Sub Bt_Hapus_Satu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Satu.Click
        Lb_2.SelectionMode = SelectionMode.One

        Lb_2.Items.Remove(Lb_2.SelectedItem)
    End Sub

    Private Sub Bt_Beberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Beberapa.Click
        Lb_1.SelectionMode = SelectionMode.MultiExtended

        Dim i, j As Integer
        j = Lb_1.Items.Count


        For i = 0 To j - 1
            Try
                Lb_2.Items.Add(Lb_1.Items(Lb_1.SelectedIndices(i)))
            Catch ex As Exception
                j -= 1
            End Try
        Next
    End Sub

    Private Sub Bt_Hapus_Beberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Beberapa.Click
        Lb_2.SelectionMode = SelectionMode.MultiExtended

        Dim i, j As Integer
        j = Lb_2.Items.Count


        For i = 0 To j - 1
            Try
                Lb_2.Items.RemoveAt(Lb_2.SelectedIndex)
            Catch ex As Exception
                j -= 1
            End Try
        Next
    End Sub
End Class