C Ffe APP C Ffe Plication: Designed & Programing Designed & Programing Mul Ahmad
C Ffe APP C Ffe Plication: Designed & Programing Designed & Programing Mul Ahmad
APPLICATION
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 Waktu
Designing 1 Jam
Coding 1 Jam
Testing and Fix Problem 1 jam
DESIGNIng
Buka aplikasi visual basic 6.0. pastikan new yang terpilih adalah Standard EXE klik Open.
Properties - form 1
Properti Value
Name Form1
Border Style 4 –Fixed. .
Caption Coffe Bean
Picture <\ beans.jpg>
Star-up position 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.
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
Double click pada timer untuk masuk ke mode coding, ketik code berikut
1 Option Explicit
2 Dim PriceKopi As Integer
3 Dim Drink As Integer
4 Dim Bean As Integer
5 Dim Temperatur As Integer
6 Dim Flavorings As Integer
7 Dim sDrink As String
8 Dim sBean As String
9 Dim sTemperatur As String
10 Dim sFlavorings As String
11 Dim indexPicture As Integer
Setelah mengetikan kode diatas, ketikan kode dibawah ini tepat dibawah kode diatas.
1 '/------------------Fungsi--------------------------------------\'
2 Private Sub Ilang(ByVal buton As String)
3 Dim z As Boolean
4 Select Case buton
5 Case "Welcome"
6 Image2.Visible = True
7 Frame1.Visible = False
8 Frame2.Visible = False
9 frFlavor.Visible = False
10 frTemp.Visible = False
11
12 Set Image1.Picture = LoadPicture(App.Path & "\welcome.jpg")
13 z = PictureChange(Image3, App.Path & "\down-welcome.jpg")
14
15 Case "Drink"
16 Image2.Visible = False
17 Frame1.Visible = True
18 Frame2.Visible = True
19 frFlavor.Visible = False
20 frTemp.Visible = False
21
22 Set Image1.Picture = LoadPicture(App.Path & "\drink size.jpg")
23 z = PictureChange(Image4, App.Path & "\down-drink size.jpg")
24
25 Case "Extras"
26 Image2.Visible = False
27 Frame1.Visible = False
28 Frame2.Visible = False
29 frFlavor.Visible = True
30 frTemp.Visible = True
31 cmdNext.Caption = "Next"
32
33 Set Image1.Picture = LoadPicture(App.Path & "\extras.jpg")
34 z = PictureChange(Image5, App.Path & "\down-extras.jpg")
35
36 Case "Summary"
37 Image2.Visible = False
38 Frame1.Visible = False
39 Frame2.Visible = False
40 frFlavor.Visible = False
41 frTemp.Visible = False
42 cmdNext.Caption = "Finish"
43 Set Image1.Picture = LoadPicture(App.Path & "\sumary.jpg")
44 z = PictureChange(Image6, App.Path & "\down-summary.jpg")
45
46 End Select
47 End Sub
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 '/------------------Button--------------------------------------\'
2 Private Sub Form_Load()
3 Ilang ("Welcome")
4 PriceKopi = 0
5 indexPicture = 1
6 End Sub
7 Private Sub Form_Unload(Cancel As Integer)
8 End
9 End Sub
Double click pada control cmdBack dan pastikan event-nya adalah click kemudian ketikan kode
berikut kedalamnya
1 If indexPicture = 0 Then Exit Sub
2 indexPicture = indexPicture - 1
3 Select Case indexPicture
4 Case 1
5 Ilang ("Welcome")
6 Case 2
7 Ilang ("Drink")
8 Case 3
9 Ilang ("Extras")
10 Case 4
11 Ilang ("Summary")
12 End Select
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 Private Sub cmdCancel_Click()
2 Dim Tanya As String
3 Tanya = MsgBox("Apakah anda yakin akan keluar", vbYesNo)
4 If Tanya = vbYes Then
5 End
6 End If
7 End Sub
8 '/------------------End Button-----------------------------------\'
a
1 '/------------------Drink Size 01--------------------------------\'
2 Private Sub dss_Click()
3 lblPrice.Caption = ": Rp. " & 2000
4 sDrink = "Your drink Size : Small"
5 Drink = 2000
6 End Sub
7
8 Private Sub dsl_Click()
9 lblPrice.Caption = ": Rp. " & 6000
10 sDrink = "Your drink Size : Large"
11 Drink = 6000
12 End Sub
13
14 Private Sub dsm_Click()
15 lblPrice.Caption = ": Rp. " & 4000
16 sDrink = "Your drink Size : Medium"
17 Drink = 4000
18 End Sub
19 '/------------------End Drink Size 01----------------------------\'
20
21 '/------------------Drink Size bean 02---------------------------\'
22 Private Sub btb_Click()
23 lblPrice.Caption = ": Rp. " & 1000
24 sBean = "Your Bean Type : Breakfast blend"
25 Bean = 1000
26 End Sub
27
28 Private Sub btf_Click()
29 lblPrice.Caption = ": Rp. " & 1500
30 sBean = "Your Bean Type : Dark roast"
31 Bean = 1500
32 End Sub
33
34 Private Sub bth_Click()
35 lblPrice.Caption = ": Rp. " & 1000
36 sBean = "Your Bean Type : House blend"
37 Bean = 1000
38 End Sub
39
40 Private Sub btl_Click()
41 lblPrice.Caption = ": Rp. " & 2000
42 sBean = "Your Bean Type : Light roast"
43 Bean = 2000
44 End Sub
45
46 Private Sub bto_Click()
47 lblPrice.Caption = ": Rp. " & 500
48 sBean = "Your Bean Type : Organic"
49 Bean = 500
50 End Sub
51 '/------------------End Drink Size bean 02-----------------------\'
a
1 '/------------------Extras--------------------------------------\'
2 Private Sub fvAB_Click()
3 lblPrice.Caption = ": Rp. " & 9000
4 sFlavorings = "Your Flavorings : Ayam bakar"
5 Flavorings = 9000
6 End Sub
7
8 Private Sub fvAG_Click()
9 lblPrice.Caption = ": Rp. " & 8000
10 sFlavorings = "Your Flavorings : Ayam goreng"
11 Flavorings = 8000
12 End Sub
13
14 Private Sub fvIB_Click()
15 lblPrice.Caption = ": Rp. " & 8500
16 sFlavorings = "Your Flavorings : Ikan bakar"
17 Flavorings = 8500
18 End Sub
19
20 Private Sub fvNG_Click()
21 lblPrice.Caption = ": Rp. " & 8000
22 sFlavorings = "Your Flavorings : Nasi goreng"
23 Flavorings = 8000
24 End Sub
25
26 Private Sub fvP_Click()
27 lblPrice.Caption = ": Rp. " & 5000
28 sFlavorings = "Your Flavorings : Pangsit"
29 Flavorings = 5000
30 End Sub
31
32 Private Sub tmE_Click()
33 lblPrice.Caption = ": Rp. " & 500
34 sTemperatur = "Your Drink temperatur : Extra hot"
35 Temperatur = 500
36 End Sub
37
38 Private Sub tmN_Click()
39 lblPrice.Caption = ": Rp. " & 0
40 sTemperatur = "Your Drink temperatur : Normal"
41 Temperatur = 0
42 End Sub
43
44 Private Sub tmW_Click()
45 lblPrice.Caption = ": Rp. " & 500
46 sTemperatur = "Your Drink temperatur : With Ice"
47 Temperatur = 500
48 End Sub
49 '/------------------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
kode-
kode apa yang dijalankan terlebih dahulu, tekan-lah
tekan F8 and more.