100% found this document useful (2 votes)
166 views12 pages

C Ffe APP C Ffe Plication: Designed & Programing Designed & Programing Mul Ahmad

Buku yang lumayan bagus ehmm..mm. dijelaskan dengan sangat-sangat jelas untuk membuat sebuah aplikasi dengan menggunakan visual basic 6

Uploaded by

mubon
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
166 views12 pages

C Ffe APP C Ffe Plication: Designed & Programing Designed & Programing Mul Ahmad

Buku yang lumayan bagus ehmm..mm. dijelaskan dengan sangat-sangat jelas untuk membuat sebuah aplikasi dengan menggunakan visual basic 6

Uploaded by

mubon
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

C FFE BEAN

APPLICATION

DESIGNED & PROGRAMING


Mul Ahmad

Programing : Visual Basic 6.0


Level : 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 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.

SPLASH SCREEN (FORM 1)

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.

FORM UTAMA (FORM 2)


Properties - form 2
Properti Value
Name Form2
Border Style 4 – Fixed. .
Caption Order Cup of Coffee
Font Verdana [8]
Icon </cupIcon.ico>
MaxButton False
MinButton False
Picture <\ beans.jpg>
Show in taskbar true
Star-up position 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>
Image5 Picture <\ on-extras.jpg> Jangan dulu buat frame 3 dan 4.
Image6 Picture <\ on-summary.jpg> Masukan terlebih dahulu
Frame1 Caption Drink size optionbar-nya kedua frame
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 Control Properti Value


1 Option button Name Dss
Caption Small
Option button Name Dsm
Caption Medium
Option button Name Dsl
Caption Large
2 Option button Name Btb
Caption Breakfast blend
Option button Name Btf
Caption Dark rost
Option button Name Bth
Caption House blend
Option button Name Btl
Caption Light roast
Option button Name Bto
Caption Organic
3 Option button Name fvP
Caption Pangsit
Option button Name fvNG
Caption Nasi goreng
Option button Name fvAG
Caption Ayam goreng
Option button Name fvAB
Caption Ayam bakar
Option button Name FvIB
Caption Ikan bakar
4 Option button Name tmN
Caption Normal
Option button Name tmE
Caption Extra hot
Option button Name tmW
Caption 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 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

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 '/------------------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

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 Private Function PictureChange(ByVal gambar As Image, ByVal Lokasi
2 As String)
3 Set Image3.Picture = LoadPicture(App.Path & "\on-welcome.jpg")
4 Set Image4.Picture = LoadPicture(App.Path & "\on-drink size.jpg")
5 Set Image5.Picture = LoadPicture(App.Path & "\on-extras.jpg")
6 Set Image6.Picture = LoadPicture(App.Path & "\on-summary.jpg")
7 Set gambar.Picture = LoadPicture(Lokasi)
8 PictureChange = True
9 End Function
10 '/------------------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 '/------------------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

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 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

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 If indexPicture = 4 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 PriceKopi = Drink + Bean + Flavorings + Temperatur
13 lblPrice = ": Rp. " & PriceKopi
14 lblSumary.Caption = sDrink & vbCrLf & sBean & _
15 vbCrLf + sFlavorings + vbCrLf + sTemperatur
16 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 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.

You might also like