Rabu, 14 April 2010
Tugas 3 Mata Kuliah Pemrograman
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
Selasa, 09 Maret 2010
Program pembelian HP Nokia
Program ini dimulai dengan memilih seri HP dan tipe HP. Setelah itu klik "Buat Pilihan". Setelah tombol itu di klik, maka data tipe yang dibeli serta detail pembayaran (tagihan) yang dibebankan kepada user.
code source:
Public Class Form1
Private Sub serie_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles serie.CheckedChanged
tipe1.Text = "E71"
tipe2.Text = "E72"
tipe3.Text = "E63"
End Sub
Private Sub serin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles serin.CheckedChanged
tipe1.Text = "N97"
tipe2.Text = "N70"
tipe3.Text = "N82"
End Sub
Private Sub serieme_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles serieme.CheckedChanged
tipe1.Text = "5800"
tipe2.Text = "N73"
tipe3.Text = ""
End Sub
Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
End
End Sub
Private Sub buatpil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buatpil.Click
tipepil.Enabled = True
harga.Enabled = True
jmltghn.Enabled = True
diskon.Enabled = True
total.Enabled = True
If tipe1.Checked = True Then
tipepil.Text = tipe1.Text
ElseIf tipe2.Checked = True Then
tipepil.Text = tipe2.Text
ElseIf tipe3.Checked = True Then
tipepil.Text = tipe3.Text
Else
MsgBox("Belum ada pilihan", MsgBoxStyle.Critical, "TAK ADA PILIHAN")
End If
Select Case tipepil.Text
Case Is = "E63"
harga.Text = 2800000
Case Is = "E71"
harga.Text = 3500000
Case Is = "E72"
harga.Text = 3800000
Case Is = "N82"
harga.Text = 2750000
Case Is = "N97"
harga.Text = 5200000
Case Is = "N70"
harga.Text = 1250000
Case Is = "N73"
harga.Text = 1500000
Case Is = "5800"
harga.Text = 4325000
Case Else
End Select
jmltghn.Text = harga.Text
If jmltghn.Text >= 3500000 Then
diskon.Text = jmltghn.Text * 0.2
Else
diskon.Text = 0
End If
total.Text = jmltghn.Text - diskon.Text
End Sub
End Class