Senin, 10 April 2017

STUDI KASUS 1 VISUAL STUDIO 2015



KODINGNYA :

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label1.Text = "APLIKASI PERHITUNGAN"
        Label3.Text = ""
        Label2.Text = ""
        RadioButton1.Text = "Penjumlahan"
        RadioButton2.Text = "Pengurangan"
        RadioButton3.Text = "Perkalian"
        RadioButton4.Text = "Pembagian"
        Button1.Text = "="
        Button2.Text = "Tambah Data Baru"
        Button3.Text = "Close"
    End Sub

    Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged

    End Sub

    Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged

    End Sub

    Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton3.CheckedChanged

    End Sub

    Private Sub RadioButton4_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton4.CheckedChanged

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim nil1 As Integer
        Dim nil2 As Integer
        Dim hasil As Integer
        nil1 = Val(TextBox1.Text)
        nil2 = Val(TextBox2.Text)
        hasil = Val(Label3.Text)
        If TextBox1.Text = "" Then
            TextBox1.Focus()
            MsgBox("anda belum memasukan nilai")
        ElseIf TextBox2.Text = "" Then
            TextBox2.Focus()
            MsgBox("anda belum memasukan nilai")
        Else

            If RadioButton1.Checked = True Then
                hasil = nil1 + nil2
                Label3.Text = hasil
                Label2.Text = "+"
                ListBox1.Items.Clear()
                ListBox1.Items.Add("----Hasil Pertambahan Adalah----")
                ListBox1.Items.Add("nilai pertama yg anda input" & TextBox1.Text)
                ListBox1.Items.Add("nilai kedua yg anda input" & TextBox2.Text)
                ListBox1.Items.Add("hasilnya" & hasil)
            End If
            If RadioButton2.Checked = True Then
                hasil = nil1 - nil2
                Label3.Text = hasil
                Label2.Text = "-"
                ListBox1.Items.Clear()
                ListBox1.Items.Add("----Hasil Pengurangan Adalah----")
                ListBox1.Items.Add("nilai pertama yg anda input" & TextBox1.Text)
                ListBox1.Items.Add("nilai kedua yg anda input" & TextBox2.Text)
                ListBox1.Items.Add("hasilnya" & hasil)
            End If
            If RadioButton3.Checked = True Then
                hasil = nil1 * nil2
                Label3.Text = hasil
                Label2.Text = "x"
                ListBox1.Items.Clear()
                ListBox1.Items.Add("----Hasil Perkalian Adalah----")
                ListBox1.Items.Add("nilai pertama yg anda input" & TextBox1.Text)
                ListBox1.Items.Add("nilai kedua yg anda input" & TextBox2.Text)
                ListBox1.Items.Add("hasilnya" & hasil)
            End If
            If RadioButton4.Checked = True Then
                hasil = nil1 / nil2
                Label3.Text = hasil
                Label2.Text = "/"
                ListBox1.Items.Clear()
                ListBox1.Items.Add("----Hasil Pembagian Adalah----")
                ListBox1.Items.Add("nilai pertama yg anda input" & TextBox1.Text)
                ListBox1.Items.Add("nilai kedua yg anda input" & TextBox2.Text)
                ListBox1.Items.Add("hasilnya" & hasil)


            End If
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ListBox1.Items.Clear()
        Label1.Text = "APLIKASI PERHITUNGAN"
        Label3.Text = ""
        Label2.Text = ""
        RadioButton1.Text = "Penjumlahan"
        RadioButton2.Text = "Pengurangan"
        RadioButton3.Text = "Perkalian"
        RadioButton4.Text = "Pembagian"
        Button1.Text = "="
        Button2.Text = "Tambah Data Baru"
        TextBox1.Clear()
        TextBox2.Clear()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Close()
    End Sub
End Class


0 komentar:

Posting Komentar