Program Mencari Nilai Akhir Mahasiswa dengan menggunakan class:
Source code:
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim z As String
Dim objKelasNilai As Kelas_Nilai
objKelasNilai = New Kelas_Nilai
z = objKelasNilai.NilaiAkhir(Val(TextBox1.Text), Val(TextBox2.Text), Val(TextBox3.Text), Val(TextBox4.Text))
TextBox5.Text = z
Label6.Text = z
Button1.Text = "Hitung"
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox1.Focus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim objKelasNilai As Kelas_Nilai
objKelasNilai = New Kelas_Nilai
objKelasNilai.DoPesan()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Public Class Kelas_Nilai
Private bil1_private, bil2_private, bil3_private, bil4_private As Integer
Public Function NilaiAkhir(ByVal bil1 As Integer, ByVal bil2 As Integer, ByVal bil3 As Integer, ByVal bil4 As Integer) As String
NilaiAkhir = bil1 * 10 / 100 + bil2 * 15 / 100 + bil3 * 35 / 100 + bil4 * 40 / 100
End Function
Public Sub DoPesan()
Dim a As Integer
a = MsgBox("Sudah Selesai", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Konfirmasi Dulu")
If a = vbYes Then
End
End If
End Sub
Public Property bil1() As String
Get
bil1 = bil1_private
End Get
Set(ByVal value As String)
bil1_private = value
End Set
End Property
Public Property bil2() As String
Get
bil2 = bil2_private
End Get
Set(ByVal value As String)
bil2_private = value
End Set
End Property
Public Property bil3() As String
Get
bil3 = bil3_private
End Get
Set(ByVal value As String)
bil3_private = value
End Set
End Property
Public Property bil4() As String
Get
bil4 = bil4_private
End Get
Set(ByVal value As String)
bil4_private = value
End Set
End Property
End Class
Tampilan:
Langganan:
Postingan (Atom)