Public Class Barang
Public kode As String = 5
Public nama As String = 10
Public satuan As Decimal
Public jumlah As Integer
Public uang As Integer
Public Property mKode() As String
Get
Return kode
End Get
Set(ByVal value As String)
kode = value
End Set
End Property
Public Property mNama() As String
Get
Return nama
End Get
Set(ByVal value As String)
nama = value
End Set
End Property
Public Property mSatuan() As Decimal
Get
Return satuan
End Get
Set(ByVal value As Decimal)
satuan = value
End Set
End Property
Public Property mJumlah() As Integer
Get
Return jumlah
End Get
Set(ByVal value As Integer)
jumlah = value
End Set
End Property
Public Function harga(ByRef mSatuan As Decimal, ByVal mJumlah As Integer) As Double
Return satuan * jumlah
End Function
Public Function promo(ByVal harga As Double)
If harga >= 2000000 Then
Return 0.06 * mSatuan * mJumlah
ElseIf harga >= 1500000 Then
Return 0.05 * mSatuan * mJumlah
ElseIf harga >= 1000000 Then
Return 0.03 * mSatuan * mJumlah
ElseIf harga >= 500000 Then
Return 0.02 * mSatuan * mJumlah
Else
Return 0
End If
End Function
Public Function total(ByVal harga As Double, ByVal promo As Double) As Double
Return harga - promo
End Function
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objbarang As New Barang
With objbarang
.kode = TextBox1.Text
.nama = TextBox2.Text
.satuan = TextBox3.Text
.jumlah = TextBox4.Text
.uang = TextBox7.Text
TextBox8.Text = TextBox7.Text - TextBox6.Text
End With
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
If TextBox3.Text * TextBox4.Text >= 2000000 Then
TextBox5.Text = 0.06 * TextBox3.Text * TextBox4.Text
TextBox6.Text = TextBox3.Text * TextBox4.Text - TextBox5.Text
ElseIf TextBox3.Text * TextBox4.Text >= 1500000 Then
TextBox5.Text = 0.05 * TextBox3.Text * TextBox4.Text
TextBox6.Text = TextBox3.Text * TextBox4.Text
ElseIf TextBox3.Text * TextBox4.Text >= 1000000 Then
TextBox5.Text = 0.03 * TextBox3.Text * TextBox4.Text
TextBox6.Text = TextBox3.Text * TextBox4.Text
Else
TextBox5.Text = 0
TextBox6.Text = TextBox3.Text * TextBox4.Text
End If
End Sub
End Class
Komentar
Posting Komentar