Rabu, 11 Maret 2015

Pertemuan 5: 9 Maret 2015 Aplikasi Perhitungan Nilai (IPK) Mahasiswa pada VB .NET


Membuat Aplikasi Perhitungan Nilai (IPK)Mahasiswa.
Pertama, kita buka dahulu VB 2010. Kemudian, klik menu File (kiri atas), pilih New Project, dan pilih Windows Form Application.


Kemudian akan muncul form kosong seperti berikut.
Buat form seperti berikut.
Kemudian masukan source codenya.


Public Class Form1

    Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
        Close()

    End Sub

    Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
        txtket.Text = ""
        txtabsen.Text = ""
        txtuts.Text = ""
        txtnama.Text = ""
        txthuruf.Text = ""
        txtrata.Text = ""
        txttugas.Text = ""
        txtuas.Text = ""
    End Sub

    Private Sub btnhitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhitung.Click
        Dim nama As String
        Dim tugas As Double
        Dim mid As Double
        Dim uas As Double
        Dim keaktifan As Double
        Dim absensi As Double
        Dim rata As Double
        Dim huruf As String
        Dim ket As String

        nama = txtnama.Text
        tugas = Val(txttugas.Text)
        keaktifan = Val(txtkeaktifan.Text)
        absensi = Val(txtabsen.Text)
        mid = Val(txtuts.Text)
        uas = Val(txtuas.Text)

        rata = ((0.2 * absensi) + (0.15 * tugas) + (0.1 * keaktifan) + (0.25 * mid) + (0.3 * tugas))
        txtrata.Text = rata

        If rata <= 39 Then
            huruf = "E"
            ket = "anda gagal"
        ElseIf rata <= 56 Then
            huruf = "D"
            ket = "cukup"
        ElseIf rata <= 69 Then
            huruf = "C"
            ket = "cukup"
        ElseIf rata <= 84 Then
            huruf = "B"
            ket = "Baik"
        ElseIf rata > 85 Then
            huruf = "A"
            ket = "Sangat Bagus"
        End If
        txthuruf.Text = huruf
        txtket.Text = ket
        txtnama1.Text = txtnama.Text

    End Sub

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

    End Sub

End Class


Dan hasilnya adalah:
Mohon maaf bila ada kesalahan kata. Sekian dan terima kasih.

Tidak ada komentar:

Posting Komentar