Hal. 75
Form cPraktikum
Public Class cPraktikum
Dim Nama As String
Dim NIM As String
Dim Group As String
Dim nHariaN As Integer
Dim nUjian As Integer
Dim nAkhir As Integer
Sub New()
Nama = "test"
NIM = "0123"
Group = "123"
nHariaN = 0
nUjian = 0
nAkhir = 0
End Sub
Sub New(ByVal nm As String, ByVal pnim As String, ByVal g As String)
Nama = nm
NIM = pnim
Group = g
End Sub
Public Property propNIM() As String
Get
Return NIM
End Get
Set(ByVal Value As String)
If Value.Length = 6 Then
NIM = Value
Else
MsgBox("NIM salah nak")
NIM = " "
End If
End Set
End Property
Public Property propNAMA() As String
Get
Return Nama
End Get
Set(ByVal value As String)
Nama = value
End Set
End Property
Public Property propGroup() As String
Get
Return Group
End Get
Set(ByVal value As String)
If value.Length = 8 Then
If Microsoft.VisualBasic.Left(value, 6).Equals("GP6106") Then
Group = value
Else
MsgBox("Group Salah Nak")
Group = " "
End If
Else
MsgBox("Group Salah Nak")
Group = " "
End If
End Set
End Property
Public Property propNharian() As Integer
Get
Return nHariaN
End Get
Set(ByVal value As Integer)
If value < 100 And value > 0 Then
nHariaN = value
Else
nHariaN = 0
End If
End Set
End Property
Public Property propNujian() As Integer
Get
Return nUjian
End Get
Set(ByVal value As Integer)
If value < 100 And value > 0 Then
nUjian = value
Else
nUjian = 0
End If
End Set
End Property
Public Property propNakhir() As Integer
Get
Return nAkhir
End Get
Set(ByVal value As Integer)
nAkhir = value
End Set
End Property
Function Hitung() As Integer
nAkhir = 0.5 * nHariaN + 0.5 * nUjian
Return nAkhir
End Function
End Class
Halaman 79
Form 1
Public Class Form1
Inherits System.Windows.Forms.Form
Dim iclass As cPraktikum
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
iclass = New cPraktikum("jack", "01234", "GP610601")
iclass.propNharian = TextBox4.Text
iclass.propNujian = TextBox5.Text
iclass.Hitung()
If iclass.propGroup.Equals("") Or iclass.propNIM.Equals("") Then
MsgBox("Data Ada yang Salah Ndul")
Else
ListBox1.Items.Add(iclass.propNAMA & vbTab & iclass.propNIM & vbTab & iclass.propGroup & vbTab & iclass.propNharian & vbTab & iclass.propNujian & vbTab & iclass.propNakhir)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
iclass = New cPraktikum
iclass.propNAMA = TextBox3.Text
iclass.propNIM = TextBox2.Text
iclass.propGroup = TextBox1.Text
iclass.propNharian = TextBox4.Text
iclass.propNujian = TextBox5.Text
iclass.Hitung()
If iclass.propGroup.Equals("") Or iclass.propNIM.Equals("") Then
MsgBox("Data Ada yang Salah")
Else
ListBox1.Items.Add(iclass.propNAMA & vbTab & iclass.propNIM & vbTab & iclass.propGroup & vbTab & iclass.propNharian & vbTab & iclass.propNujian & vbTab & iclass.propNakhir)
End If
End Sub
End Class
0 komentar
Posting Komentar