Senin, 10 April 2017

STUDI KASUS 2 VISUAL STUDIO 2015



KODINGNYA :


Public Class Form1
    Dim hewan, buah As Integer
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Then
            TextBox1.Text = ""
            TextBox1.Focus()
            MsgBox("Anda belum memasukan Inputan pertama")
        ElseIf TextBox2.Text = "" Then
            TextBox2.Text = ""
            TextBox2.Focus()
            MsgBox("Anda belum memasukan Inputan kedua")
        Else

            If TextBox1.Text = "Macan Tutul" Or TextBox1.Text = "Kanguru" Or TextBox1.Text = "Landak" Or TextBox1.Text = "Gajah" Or TextBox1.Text = "Buaya" Then
                hewan = 1
            ElseIf TextBox1.Text = "Nanas" Or TextBox1.Text = "Manggis" Or TextBox1.Text = "Anggur" Or TextBox1.Text = "Durian" Or TextBox1.Text = "Apel" Then
                hewan = 2
            End If
            If TextBox2.Text = "Macan Tutul" Or TextBox2.Text = "Kanguru" Or TextBox2.Text = "Landak" Or TextBox2.Text = "Gajah" Or TextBox2.Text = "Buaya" Then
                buah = 1
            ElseIf TextBox2.Text = "Nanas" Or TextBox2.Text = "Manggis" Or TextBox2.Text = "Anggur" Or TextBox2.Text = "Durian" Or TextBox2.Text = "Apel" Then
                buah = 2
            End If
        End If

        If hewan = 1 And buah = 1 Then
            MsgBox("Keduanya adalah hewan", MsgBoxStyle.Information)
        ElseIf hewan = 2 And buah = 2 Then
            MsgBox("Keduanya adalah buah", MsgBoxStyle.Information)
        ElseIf hewan <> buah Then
            MsgBox("Keduanya tidak sebanding karena keduanya berbeda", MsgBoxStyle.Critical)
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox1.Focus()
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Clear()
        TextBox2.Clear()
    End Sub
End Class


0 komentar:

Posting Komentar