Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. Public Class Form1
  2. Private Sub BtnHitung_Click(sender As Object, e As EventArgs) Handles BtnHitung.Click
  3. ' membuat variable untuk menampung data dari masing - masing combobox
  4. Dim pilihan1 As Integer
  5. Dim pilihan2 As Integer
  6. Dim pilihan3 As Integer
  7. Dim pilihan4 As Integer
  8. ' membuat variable untuk menampung data dari masing - masing textbox
  9. Dim harga1 As Integer
  10. Dim harga2 As Integer
  11. Dim harga3 As Integer
  12. Dim harga4 As Integer
  13. ' membuat variable untuk menampung hasil perhitungan total harga
  14. Dim totalHarga1 As Integer
  15. Dim totalHarga2 As Integer
  16. Dim totalHarga3 As Integer
  17. Dim totalHarga4 As Integer
  18.  
  19. ' mengisi variable combobox
  20. pilihan1 = Cb1.SelectedItem
  21. pilihan2 = Cb2.SelectedItem
  22. pilihan3 = Cb3.SelectedItem
  23. pilihan4 = Cb4.SelectedItem
  24.  
  25. ' mengisi variable textbox
  26. harga1 = Integer.Parse(TbHarga1.Text)
  27. harga2 = Integer.Parse(TbHarga2.Text)
  28. harga3 = Integer.Parse(TbHarga3.Text)
  29. harga4 = Integer.Parse(TbHarga4.Text)
  30.  
  31. ' Hitung total harga berdasarkan jumlah kuantity dari combobox * harga
  32. totalHarga1 = pilihan1 * harga1
  33. totalHarga2 = pilihan2 * harga2
  34. totalHarga3 = pilihan3 * harga3
  35. totalHarga4 = pilihan4 * harga4
  36.  
  37. ' Cetak Jumlah Harga
  38. Dim currencyTotal = Integer.Parse(totalHarga1) + Integer.Parse(totalHarga2) + Integer.Parse(totalHarga3) + Integer.Parse(totalHarga4)
  39.  
  40. ' cek diskon
  41. If CBoxDiskon1.Checked = True Then
  42. currencyTotal = currencyTotal + 2
  43. End If
  44.  
  45. ' merubah cultureinfo menjadi indonesia
  46. System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("id-ID")
  47. System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("id-ID")
  48. LblTotal.Text = FormatCurrency(currencyTotal)
  49.  
  50.  
  51. If currencyTotal > 5000 And currencyTotal <= 10000 Then
  52. PbBonus.Image = My.Resources.kucing_galau
  53. LblBonus.Text = "Anda Mendapatkan Bonus Kucing Galau"
  54. Else
  55. PbBonus.Image = Nothing
  56. LblBonus.Text = "Anda Tidak mendapat Bonus"
  57. End If
  58.  
  59.  
  60. End Sub
  61.  
  62.  
  63.  
  64. Private Sub DdDiskon_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdDiskon1.SelectedIndexChanged
  65. Dim persen1 As Integer
  66. persen1 = DdDiskon1.SelectedItem * Integer.Parse(TbHarga1.Text) / 100
  67. TbDiskon1.Text = Integer.Parse(TbHarga1.Text) - persen1
  68. End Sub
  69.  
  70. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  71. DdDiskon1.Enabled = False
  72. TbDiskon1.Enabled = False
  73.  
  74. DdDiskon2.Enabled = False
  75. TbDiskon2.Enabled = False
  76.  
  77. ' tambahkan 4 component lagi yang belum
  78. End Sub
  79.  
  80. Private Sub Cb1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Cb1.SelectedIndexChanged
  81. Dim hargaProduk1 As Integer = 10000
  82. TbHarga1.Text = Cb1.SelectedItem * hargaProduk1
  83. TbDiskon1.Text = Cb1.SelectedItem * hargaProduk1
  84. End Sub
  85.  
  86. Private Sub Cb2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Cb2.SelectedIndexChanged
  87. Dim hargaProduk2 As Integer = 20000
  88. TbHarga2.Text = Cb2.SelectedItem * hargaProduk2
  89. TbDiskon2.Text = Cb2.SelectedItem * hargaProduk2
  90. End Sub
  91.  
  92. Private Sub CBoxDiskon_CheckedChanged(sender As Object, e As EventArgs) Handles CBoxDiskon1.CheckedChanged
  93.  
  94. If CBoxDiskon1.Checked = True Then
  95.  
  96. DdDiskon1.Enabled = True
  97. TbDiskon1.Enabled = True
  98. Else
  99. DdDiskon1.Enabled = False
  100. TbDiskon1.Enabled = False
  101. End If
  102. End Sub
  103.  
  104. Private Sub CboxDiskon2_CheckedChanged(sender As Object, e As EventArgs) Handles CboxDiskon2.CheckedChanged
  105.  
  106. End Sub
  107. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement