Senin, 10 April 2017

Tugas Looping


KODINGNYA :

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label1.Text = "S/D"
        Label2.Text = "Kalikan Berapa ?"
        RadioButton1.Text = "Tunggal"
        RadioButton2.Text = "Sampai"
        Button1.Text = "OK"
        Button2.Text = "Add"
        Button3.Text = "Close"
        Button4.Text = "Clear"
        nonaktif()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If RadioButton2.Checked = True Then
            Dim A, B, C As Integer
            ListBox1.Items.Clear()
            For A = TextBox1.Text To TextBox2.Text
                For B = 1 To TextBox3.Text
                    C = A * B
                    If A = 1 Then
                        ListBox1.Items.Add(A & "x" & B & "=" & C)
                    ElseIf A = 2 Then
                        ListBox1.Items.Add(A & "x" & B & "=" & C)
                    Else
                        ListBox1.Items.Add(A & "x" & B & "=" & C)
                    End If
                Next
                ListBox1.Items.Add("--------------")
            Next

        ElseIf RadioButton1.Checked = True Then

            Dim A, B, C As Integer
            ListBox1.Items.Clear()
            For A = 1 To TextBox3.Text
                For B = 1 To TextBox3.Text
                    C = A * B
                    If A = 1 Then
                        ListBox1.Items.Add(A & "x" & B & "=" & C)
                    ElseIf A = 2 Then
                        ListBox1.Items.Add(A & "x" & B & "=" & C)
                    Else
                        ListBox1.Items.Add(A & "x" & B & "=" & C)
                    End If
                Next
                ListBox1.Items.Add("--------------")
            Next
        End If
    End Sub

    Function hit(ByVal a As Integer, ByVal b As Integer)
        Dim has As Integer
        has = a * b
        Return (has)
    End Function
    Sub aktif()
        TextBox1.Enabled = True
        TextBox2.Enabled = True
        TextBox3.Enabled = True
        Button1.Enabled = True
    End Sub
    Sub nonaktif()
        TextBox1.Enabled = False
        TextBox2.Enabled = False
        TextBox3.Enabled = False
        Button1.Enabled = False
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        aktif()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        MsgBox("Keluar yaa hehe^^")
        Close()
    End Sub
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        ListBox1.Items.Clear()
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
    End Sub
    Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GroupBox1.Enter

    End Sub
End Class


0 komentar:

Posting Komentar