Coffe Bean

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Coffe Bean as PDF for free.

More details

  • Words: 2,042
  • Pages: 12
C FFE BEAN APPLICATION

DESIGNED & PROGRAMING Mul Ahmad

Programing Level

: Visual Basic 6.0 : Beginner

PLANNIng ALGORITMA Start

Show Splash screen in 3 seconds

Show FORM UTAMA

Input 1 Drink size & Bean

Input 2 Flavorings & Drink Temperatur

Price = Input 1 + Input 2

Show Summary of Input

Finish

KERANGKA

TIME SHCEDULE Nama Designing Coding Testing and Fix Problem

Waktu 1 Jam 1 Jam 1 jam

DESIGNIng Buka aplikasi visual basic 6.0. pastikan new yang terpilih adalah Standard EXE klik Open.

SPLASH SCREEN (FORM 1) Properties - form 1 Properti Name Border Style Caption Picture Star-up position

Value Form1 4 –Fixed. . Coffe Bean <\ beans.jpg> 2-center . .

Masukan sebuah control tImer yang terdapat dalam toolbox ke Form 1, anda bisa double click pada timer di toolbox untuk memasukannya kedalam form. Setelah itu atur properti interval = 3000 yang nilainya sama dengan 3 detik.

FORM UTAMA (FORM 2) Properties - form 2 Properti Name Border Style Caption Font Icon MaxButton MinButton Picture Show in taskbar Star-up position

Value Form2 4 – Fixed. . Order Cup of Coffee Verdana [8] False False <\ beans.jpg> true 2-center screen . .

Kemudian tambahkan beberapa control berikut: Control & Name Properti Value Lihatlah gambar kerangka Image1 Picture <\ welcome.jpg> diatas untuk mengatur image Image2 Picture <\ cupicon.png> yang ada. Image3 Picture <\ on-welcome.jpg> Image4 Picture <\ on-drink size.jpg> Jangan dulu buat frame 3 dan 4. Image5 Picture <\ on-extras.jpg> Masukan terlebih dahulu Image6 Picture <\ on-summary.jpg> optionbar-nya kedua frame Frame1 Caption Drink size Frame2 Caption Bean type tersebut lalu buat frame 3 dan Frame3 Caption Flavorings 4 Frame4 Caption Temperatur Oh ya.. atur properti visible ke empat frame tersebut dengan value false

Setelah anda melalui tahap diatas, masukan beberapa control lagi pada frame-frame yang telah anda buat sebelumnya. Agar control-control tersebut masuk kedalam frame-nya masing-masing, sebelum anda menciptakan control terlebih dahulu click frame yang akan dimasukan control. Frame 1

Control Option button Option button Option button

2

Option button Option button Option button Option button Option button

3

Option button Option button Option button Option button Option button

4

Option button Option button Option button

Properti Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption Name Caption

Value Dss Small Dsm Medium Dsl Large Btb Breakfast blend Btf Dark rost Bth House blend Btl Light roast Bto Organic fvP Pangsit fvNG Nasi goreng fvAG Ayam goreng fvAB Ayam bakar FvIB Ikan bakar tmN Normal tmE Extra hot tmW With Ice

Setelah membuat dan mengatur control diatas, buatlah beberapa control berikut ini, lagi!!! Control & Name Properti Value Label Caption Price Label Caption : Command button Name cmdBack Caption Back Command button Name cmdNext Caption Next Command button Name cmdCancel Caption Cancel Oh ya.. atur properti Autosize : True dan backstyle : 0 - transparant untuk kedua label tersebut.

CODIng SPLASH SCREEN (FORM 1) Double click pada timer untuk masuk ke mode coding, ketik code berikut

1 Private Sub Timer1_Timer() 2 Form2.Show 3 Form1.Hide 4 Timer1.Enabled = False 5 End Sub

Arti kode diatas yaitu: 1. Baris 1 dan 5 merupakan sub mulai dan akhir sub dari control timer dan event timer 2. Baris ke-2 berfungsi untuk menampilkan form2 3. Baris ke-3 berfungsi untuk menyembunyikan form1 4. Baris ke-4 berfungsi untuk menon-aktifkan timer1

FORM UTAMA (FORM 2) Masuk kedalam mode coding untuk form2, kemudian ketik kode berikut:

1 2 3 4 5 6 7 8 9 10 11

Option Explicit Dim PriceKopi As Integer Dim Drink As Integer Dim Bean As Integer Dim Temperatur As Integer Dim Flavorings As Integer Dim sDrink As String Dim sBean As String Dim sTemperatur As String Dim sFlavorings As String Dim indexPicture As Integer

Arti kode diatas yaitu: 1. Baris pertama mengaktifkan option explicit 2. Baris ke-2 dan s/d ke-11 mendeklarasikan sebuah variabel dengan berbagai tipe dengan fungsi Dim ( Dim [Nama_Variabel] as [TipeData] ) Setelah mengetikan kode diatas, ketikan kode dibawah ini tepat dibawah kode diatas.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

'/------------------Fungsi--------------------------------------\' Private Sub Ilang(ByVal buton As String) Dim z As Boolean Select Case buton Case "Welcome" Image2.Visible = True Frame1.Visible = False Frame2.Visible = False frFlavor.Visible = False frTemp.Visible = False Set Image1.Picture = LoadPicture(App.Path & "\welcome.jpg") z = PictureChange(Image3, App.Path & "\down-welcome.jpg") Case "Drink" Image2.Visible = Frame1.Visible = Frame2.Visible = frFlavor.Visible frTemp.Visible =

False True True = False False

Set Image1.Picture = LoadPicture(App.Path & "\drink size.jpg") z = PictureChange(Image4, App.Path & "\down-drink size.jpg") Case "Extras" Image2.Visible = False Frame1.Visible = False Frame2.Visible = False frFlavor.Visible = True frTemp.Visible = True cmdNext.Caption = "Next" Set Image1.Picture = LoadPicture(App.Path & "\extras.jpg") z = PictureChange(Image5, App.Path & "\down-extras.jpg") Case "Summary" Image2.Visible = False Frame1.Visible = False Frame2.Visible = False frFlavor.Visible = False frTemp.Visible = False cmdNext.Caption = "Finish" Set Image1.Picture = LoadPicture(App.Path & "\sumary.jpg") z = PictureChange(Image6, App.Path & "\down-summary.jpg") End Select End Sub

Arti kode diatas yaitu: 1. Baris pertama merupakan komentar, komentar diawali dengan ‘ini komentar 2. Baris ke-2 dan ke-47 merupakan sub buatan dengan 1 parameter dengan tipe string. Sub ini berfungsi untuk mengatur tata letak control-control dari program yang anda buat. 3. Baris ke-4 dan ke-46 merupakan awal dan akhir dari select case.. 4. Jika properti visible=false maka control tersebut tidak akan ditampilkan terkecuali properti visible-nya true 5. Pada baris ke-12 berfungsi untuk menset control image1 properti picture bervalue [path aplikasi] \welcome.jpg 6. Pada baris ke-13 berfungsi untuk memanggil fungsi buatan PictureChange 7. Baris ke-42 berfungsi untuk merubah value properti caption cmdNext menjadi Finish

1 2 3 4 5 6 7 8 9 10

Private Function PictureChange(ByVal gambar As Image, ByVal Lokasi As String) Set Image3.Picture = LoadPicture(App.Path & "\on-welcome.jpg") Set Image4.Picture = LoadPicture(App.Path & "\on-drink size.jpg") Set Image5.Picture = LoadPicture(App.Path & "\on-extras.jpg") Set Image6.Picture = LoadPicture(App.Path & "\on-summary.jpg") Set gambar.Picture = LoadPicture(Lokasi) PictureChange = True End Function '/------------------End Fungsi-----------------------------------\'

Arti kode diatas yaitu: 1. Baris ke-1 dan ke-4 merupakan awal dan akhir fungsi, yang berguna untuk merubah gambar dari image-image sebelah kiri. 2. Baris ke-9 berfungsi untuk mengembalikan nilai Picture change dengan nilai True (kalo pada pemograman C return true) Sesuaikan kode dibawah ini pada form_load dan form_unload. Untuk mengganti ke event unload caranya pastikan kursor berada dalam form_load. Kemudian ganti event ke unload 1 2 3 4 5 6 7 8 9

'/------------------Button--------------------------------------\' Private Sub Form_Load() Ilang ("Welcome") PriceKopi = 0 indexPicture = 1 End Sub Private Sub Form_Unload(Cancel As Integer) End End Sub

Arti kode diatas yaitu: 1. Baris ke-3 berfungsi untuk memanggil sub buatan ilang dengan value parameter “welcome” 2. Baris ke-2 berfungsi untuk memberikan value 0 kepada variabel PriceKopi 3. Baris ke-8 berfungsi untuk mematikan/ close program Double click pada control cmdBack dan pastikan event-nya adalah click kemudian ketikan kode berikut kedalamnya 1 2 3 4 5 6 7 8 9 10 11 12

If indexPicture = 0 Then Exit Sub indexPicture = indexPicture - 1 Select Case indexPicture Case 1 Ilang ("Welcome") Case 2 Ilang ("Drink") Case 3 Ilang ("Extras") Case 4 Ilang ("Summary") End Select

Arti kode diatas yaitu: 1. Baris ke-1, jika value indexPicture adalah 0 maka perintah dalam sub itu tidak akan dikerjakan sama sekali

Setelah mengetik terlebih mengerti kode diatas, silahkan lanjutkan dengan double click pada cmdNext dan ketik kode dibawah ini dalam sub cmdNext pastikan juga event-nya adalah click.: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

If indexPicture = 4 Then Exit Sub indexPicture = indexPicture + 1 Select Case indexPicture Case 1 Ilang ("Welcome") Case 2 Ilang ("Drink") Case 3 Ilang ("Extras") Case 4 Ilang ("Summary") PriceKopi = Drink + Bean + Flavorings + Temperatur lblPrice = ": Rp. " & PriceKopi lblSumary.Caption = sDrink & vbCrLf & sBean & _ vbCrLf + sFlavorings + vbCrLf + sTemperatur End Select

Arti kode diatas: 1. Anda pasti sudah mengetahui sebagian besar fungsi-fungsi kode diatas. 2. Pada baris ke-14 berfungsi untuk merubah properti caption dari control lblSumary. vbCrLf berfungsi untuk membuat baris baru. Operator “+” dan “&” fungsinya sama untuk string. Setelah mengetik terlebih mengerti kode diatas, silahkan lanjutkan dengan double click pada cmdCancel dan sesuaikan kode dibawah ini dalam sub cmdCancel pastikan juga event-nya adalah click.: 1 2 3 4 5 6 7 8

Private Sub cmdCancel_Click() Dim Tanya As String Tanya = MsgBox("Apakah anda yakin akan keluar", vbYesNo) If Tanya = vbYes Then End End If End Sub '/------------------End Button-----------------------------------\'

a 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

'/------------------Drink Size 01--------------------------------\' Private Sub dss_Click() lblPrice.Caption = ": Rp. " & 2000 sDrink = "Your drink Size : Small" Drink = 2000 End Sub Private Sub dsl_Click() lblPrice.Caption = ": Rp. " & 6000 sDrink = "Your drink Size : Large" Drink = 6000 End Sub Private Sub dsm_Click() lblPrice.Caption = ": Rp. " & 4000 sDrink = "Your drink Size : Medium" Drink = 4000 End Sub '/------------------End Drink Size 01----------------------------\' '/------------------Drink Size bean 02---------------------------\' Private Sub btb_Click() lblPrice.Caption = ": Rp. " & 1000 sBean = "Your Bean Type : Breakfast blend" Bean = 1000 End Sub Private Sub btf_Click() lblPrice.Caption = ": Rp. " & 1500 sBean = "Your Bean Type : Dark roast" Bean = 1500 End Sub Private Sub bth_Click() lblPrice.Caption = ": Rp. " & 1000 sBean = "Your Bean Type : House blend" Bean = 1000 End Sub Private Sub btl_Click() lblPrice.Caption = ": Rp. " & 2000 sBean = "Your Bean Type : Light roast" Bean = 2000 End Sub Private Sub bto_Click() lblPrice.Caption = ": Rp. " & 500 sBean = "Your Bean Type : Organic" Bean = 500 End Sub '/------------------End Drink Size bean 02-----------------------\'

a 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

'/------------------Extras--------------------------------------\' Private Sub fvAB_Click() lblPrice.Caption = ": Rp. " & 9000 sFlavorings = "Your Flavorings : Ayam bakar" Flavorings = 9000 End Sub Private Sub fvAG_Click() lblPrice.Caption = ": Rp. " & 8000 sFlavorings = "Your Flavorings : Ayam goreng" Flavorings = 8000 End Sub Private Sub fvIB_Click() lblPrice.Caption = ": Rp. " & 8500 sFlavorings = "Your Flavorings : Ikan bakar" Flavorings = 8500 End Sub Private Sub fvNG_Click() lblPrice.Caption = ": Rp. " & 8000 sFlavorings = "Your Flavorings : Nasi goreng" Flavorings = 8000 End Sub Private Sub fvP_Click() lblPrice.Caption = ": Rp. " & 5000 sFlavorings = "Your Flavorings : Pangsit" Flavorings = 5000 End Sub Private Sub tmE_Click() lblPrice.Caption = ": Rp. " & 500 sTemperatur = "Your Drink temperatur : Extra hot" Temperatur = 500 End Sub Private Sub tmN_Click() lblPrice.Caption = ": Rp. " & 0 sTemperatur = "Your Drink temperatur : Normal" Temperatur = 0 End Sub Private Sub tmW_Click() lblPrice.Caption = ": Rp. " & 500 sTemperatur = "Your Drink temperatur : With Ice" Temperatur = 500 End Sub '/------------------End Extras-----------------------------------\'

TESTIng Akhirnya sampai juga pada tahap ini. Setelah anda yakin telah melakukan semua yang dilakukan diatas, sekarang waktunya anda mentes program yang telah dibuat. Klik Start yang terdapat di toolbar untuk menjalankan program F5 untuk keyboard-nya. keyboard nya. Jika anda ingin full compile tekan Ctrl+F5. Cobalah program tersebut, dan lihatlah apakah masih ada bug atau tidak. Jika masih ada bug carilah dimana letak-nya nya dan perbaiki sampai program yang anda buat benar-benar benar benar sesuai dengan apa yang diharapkan dalam tulisan ini. Untuk menghentikan program klik Stop yang terdapat dalam toolbar. Sekedar informasi, anda tidak dapat melakukan mengedit engedit coding ketika program tersebut masih jalan. Untuk melihat kode kodekode apa yang dijalankan terlebih dahulu, tekan-lah tekan F8 and more.

Related Documents

Coffe Bean
May 2020 18
Coffe
November 2019 19
Bean
October 2019 21
Coffe Free.docx
June 2020 19
Starbucks Coffe
November 2019 24
Sawney Bean
August 2019 16