Senin, 10 April 2017

Tugas Input Box, Procedure, Function



KODINGNYA :

Public Class Form1
    Dim jk As String
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        ListBox1.Items.Remove(ListBox1.SelectedItem)
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        nonaktif()

    End Sub

    Sub nonaktif()
        Label1.Text = "Nama Lengkap"
        Label2.Text = "Tempat Tanggal Lahir"
        RadioButton1.Text = "Laki Laki"
        RadioButton2.Text = "Perempuan"
        Label3.Text = "Jenis Kelamin"
        Label4.Text = "Alamat"
        Label5.Text = "Nama Orangtua"
        Label6.Text = "Tinggi Badan"
        Label7.Text = "Usia"
        Label8.Text = "Berat Badan"
        Label9.Text = "Riwayat Penyakit"
        Label10.Text = ""
        Label11.Text = ""
        Label12.Text = ""
        Label13.Text = ""
        Label14.Text = ""
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        Button1.Text = "Tambah"
        Button2.Text = "Simpan"
        Button3.Text = "Hapus"
        Button4.Text = "Bersih"
        Button5.Text = "Tambah Data"
        TextBox1.Enabled = False
        TextBox2.Enabled = False
        DateTimePicker1.Enabled = False
        RadioButton1.Enabled = False
        RadioButton2.Enabled = False
        TextBox3.Enabled = False
        TextBox4.Enabled = False
        Button5.Enabled = False
    End Sub

    Sub aktif()
        TextBox1.Enabled = True
        TextBox2.Enabled = True
        DateTimePicker1.Enabled = True
        RadioButton1.Enabled = True
        RadioButton2.Enabled = True
        TextBox3.Enabled = True
        TextBox4.Enabled = True
        Button5.Enabled = True
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        aktif()
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim a As Integer
        Label10.Text = InputBox("Masukan tinggi badan anda")
        Label11.Text = InputBox("Masukan usia anda")
        Label12.Text = InputBox("Masukan berat badan anda")
        Label13.Text = InputBox("Riwayat Penyakit")
        a = ket(Label10.Text, Label12.Text)
        If a = 0 Then
            Label14.Text = "LULUS"
            Button2.Enabled = True
        ElseIf a = 1 Then
            Label14.Text = "TIDAK LULUS"
            Button2.Enabled = False
        End If
    End Sub

    Function ket(ByVal a As Integer, ByVal b As Integer)
        If a >= 180 And b <= 80 Then
            ket = 0
        Else
            ket = 1
        End If
    End Function

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If RadioButton1.Checked = True Then
            jk = "Laki Laki"
        ElseIf RadioButton2.Checked = True Then
            jk = "Perempuan"
        End If

        With ListBox1
            .Items.Add(TextBox1.Text)
            .Items.Add(TextBox2.Text)
            .Items.Add(DateTimePicker1.Text)
            .Items.Add(jk)
            .Items.Add(TextBox3.Text)
            .Items.Add(TextBox4.Text)
            .Items.Add(Label10.Text)
            .Items.Add(Label11.Text)
            .Items.Add(Label12.Text)
            .Items.Add(Label13.Text)
        End With

        nonaktif()
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        ListBox1.Items.Clear()
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        nonaktif()
    End Sub
End Class


0 komentar:

Posting Komentar