Program Restoran dengan menggunakan Class
Public Class Class1
Public Function fharga(ByVal Harga As Integer, ByVal Jumlah As Integer) As Integer
fharga = Harga * Jumlah
End Function
Public Function fpembayaran(ByVal bil1 As Integer, ByVal bil2 As Integer, ByVal bil3 As Integer, ByVal bil4 As Integer, ByVal bil5 As Integer, ByVal bil6 As Integer, ByVal bil7 As Integer, ByVal bil8 As Integer) As Integer
fpembayaran = Val(bil1) + Val(bil2) + Val(bil3) + Val(bil4) + Val(bil5) + Val(bil6) + Val(bil7) + Val(bil8)
End Function
End Class
-----------------------------------------------------------------------------
Public Class Class2
Public Function fharga(ByVal Harga As Integer, ByVal Jumlah As Integer) As Integer
fharga = Harga * Jumlah
End Function
End Class
-------------------------------------------------------------------------------------
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim harga As New Class1
TextBox1.Text = harga.fharga(Label9.Text, ComboBox1.Text)
TextBox2.Text = harga.fharga(Label10.Text, ComboBox2.Text)
TextBox3.Text = harga.fharga(Label11.Text, ComboBox3.Text)
TextBox4.Text = harga.fharga(Label12.Text, ComboBox4.Text)
TextBox5.Text = harga.fharga(Label13.Text, ComboBox5.Text)
TextBox6.Text = harga.fharga(Label14.Text, ComboBox6.Text)
TextBox7.Text = harga.fharga(Label15.Text, ComboBox7.Text)
TextBox8.Text = harga.fharga(Label16.Text, ComboBox8.Text)
Dim obj As New Class1
Label18.Text = obj.fpembayaran(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text, TextBox7.Text, TextBox8.Text)
MsgBox("Total Harga adalah Rp " + Label18.Text + " ")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Hasilnya
Rabu, 14 April 2010
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar