Public Class Owner
Private XBos As String
Private XWak As String
Public Property Nama_Bos() As String
Get
Return XBos
End Get
Set(ByVal value As String)
XBos = value
End Set
End Property
Public Property Nama_Wakil() As String
Get
Return XWak
End Get
Set(ByVal value As String)
XWak = value
End Set
End Property
End Class
lalu, class owner diwariskan ke subclass karyawan
Public Class Karyawan
Inherits Owner
Private Xkar As String
Private Xusia As Byte
Public Property Nama_Karyawan() As String
Get
Return Xkar
End Get
Set(ByVal value As String)
Xkar = value
End Set
End Property
Public Property Usia_Karyawan() As Byte
Get
Return Xusia
End Get
Set(ByVal value As Byte)
Xusia = value
End Set
End Property
End Class
Inherits Owner
Private Xkar As String
Private Xusia As Byte
Public Property Nama_Karyawan() As String
Get
Return Xkar
End Get
Set(ByVal value As String)
Xkar = value
End Set
End Property
Public Property Usia_Karyawan() As Byte
Get
Return Xusia
End Get
Set(ByVal value As Byte)
Xusia = value
End Set
End Property
End Class
lalu setelah subclass karyawan jadi subclass karyawan diwariskan ke subclass pekerjaan
Public Class Pekerjaan
Inherits Karyawan
Private XKerja As String
Public Property Jenis_Pekerjaan() As String
Get
Return XKerja
End Get
Set(ByVal value As String)
XKerja = value
End Set
End Property
End Class
Inherits Karyawan
Private XKerja As String
Public Property Jenis_Pekerjaan() As String
Get
Return XKerja
End Get
Set(ByVal value As String)
XKerja = value
End Set
End Property
End Class
kemudian buat form seperti ini
Gambar 1
lalu ketik kode ini pada form load.
ComboBox1.Items.Add("Laki-Laki")
ComboBox1.Items.Add("Wanita")
lalu klik dua kali tombol proses dan isikan kode ini.
Dim obj_kerja As New Pekerjaan
With obj_kerja
.Nama_Bos = TextBox1.Text
.Nama_Wakil = TextBox2.Text
.Nama_Karyawan = TextBox3.Text
If ComboBox1.Text = "Laki-Laki" Then
.Jenis_Pekerjaan = "Angkat Barang"
Else
.Jenis_Pekerjaan = "Jahit"
End If
End With
With ListView1.Items
.Add("Nama Bos : " & _
obj_kerja.Nama_Bos)
.Add("Nama Wakil : " & _
obj_kerja.Nama_Wakil)
.Add("Nama Karyawan : " & _
obj_kerja.Nama_Karyawan)
.Add("Jenis Kelamin : " & _
ComboBox1.Text)
.Add("Jenis Pekerjaan : " & _
obj_kerja.Jenis_Pekerjaan)
End With
Selamat Mencoba.... :Dc
0 comments:
Post a Comment