Selasa, 05 April 2016

Pertemuan 5

1. Buat Projek baru
2. buat tampilan seperti dibawah ini

3. masukan koding dibawah ini

Public Class Form1
    Private Sub btn_hitung_Click(sender As Object, e As EventArgs) Handles btn_hitung.Click
        Dim skor1 As Double
        Dim skor2 As Double
        Dim skor3 As Double
        Dim rata2 As Double

        Const num_scores As Integer = 3 ' jumlah skor yang ada, dihitung menurut jumlah tex box
        Const high_scores As Integer = 95.0

        Try
            skor1 = CDbl(txt_skor1.Text)
            skor2 = CDbl(txt_skor2.Text)
            skor3 = CDbl(txt_skor3.Text)

            rata2 = (skor1 + skor2 + skor3) / num_scores

            lbl_rata.Text = rata2.ToString("n2")

            If rata2 > high_scores Then lbl_ucapan.Text = "Selamat !! Nilai anda bagus"

        Catch
            lbl_ucapan.Text = "Scores harus angka"

        Catch ex As Exception

        End Try

    End Sub

    Private Sub btn_clear_Click(sender As Object, e As EventArgs) Handles btn_clear.Click
        txt_skor1.Clear()
        txt_skor2.Clear()
        txt_skor3.Clear()
        lbl_rata.Text = ""
        lbl_ucapan.Text = ""
    End Sub

    Private Sub btn_exit_Click(sender As Object, e As EventArgs) Handles btn_exit.Click
        Me.Close()

    End Sub
End Class

latihan 2

1. Buat form baru
2. buat interface seperti dibawah ini

3. Masukan koding dibawah ini
Public Class Form2
    Private Sub btn_hitung_Click(sender As Object, e As EventArgs) Handles btn_hitung.Click

        Dim skor1 As Double
        Dim skor2 As Double
        Dim skor3 As Double
        Dim rata2 As Double

        Const num_scores As Integer = 3 ' jumlah skor yang ada, dihitung menurut jumlah tex box
        Const high_scores As Integer = 95.0


        skor1 = CDbl(txt_skor1.Text)
            skor2 = CDbl(txt_skor2.Text)
            skor3 = CDbl(txt_skor3.Text)

            rata2 = (skor1 + skor2 + skor3) / num_scores

            lbl_rata.Text = rata2.ToString("n2")

        If rata2 > high_scores Then
            lbl_ucapan.Text = "Selamat !! Nilai anda bagus"
        Else
            lbl_ucapan.Text = "Coba Lagi"
        End If



    End Sub

    Private Sub btn_clear_Click(sender As Object, e As EventArgs) Handles btn_clear.Click
        txt_skor1.Clear()
        txt_skor2.Clear()
        txt_skor3.Clear()
        lbl_rata.Text = ""
        lbl_ucapan.Text = ""
    End Sub

    Private Sub btn_exit_Click(sender As Object, e As EventArgs) Handles btn_exit.Click
        Me.Close()

    End Sub
End Class


Latihan 3
1. buat form baru
2. buat interface seperti dibawah ini


3. Masukan koding dibawah ini
Public Class Form3
    Private Sub btn_hitung_Click(sender As Object, e As EventArgs) Handles btn_hitung.Click
        Dim skor1 As Double
        Dim skor2 As Double
        Dim skor3 As Double
        Dim rata2 As Double

        Const num_scores As Integer = 3 ' jumlah skor yang ada, dihitung menurut jumlah tex box
        Const high_scores As Integer = 95.0


        skor1 = CDbl(txt_skor1.Text)
        skor2 = CDbl(txt_skor2.Text)
        skor3 = CDbl(txt_skor3.Text)

        rata2 = (skor1 + skor2 + skor3) / num_scores

        lbl_rata.Text = rata2.ToString("n2")

        If rata2 > high_scores Then
            lbl_ucapan.Text = "Selamat !! Nilai anda bagus"
        Else
            lbl_ucapan.Text = "Coba Lagi"
        End If
    End Sub

End Class



























Tidak ada komentar:

Posting Komentar