Kamis, 02 Oktober 2014

“Latihan CheckBox” dengan Visual Basic 6.0

VB6SP6_logo

“Latihan CheckBox” yang terdapat pada eBook “Panduan Praktik Pemrograman Komputer”.

Tidak banyak modifikasi yang dibuat. Hanya sekedar menambahkan fitur tombol “Baru”. Untuk lebih lengkapnya dapat dilihat pada kode sumber yang disertakan.

 

 

Latihan_Checkbox

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Toko Alat Tulis"
ClientHeight = 2535
ClientLeft = 45
ClientTop = 405
ClientWidth = 5670
BeginProperty Font
Name = "Segoe UI"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2535
ScaleWidth = 5670
StartUpPosition = 2 'CenterScreen
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 9
Top = 2160
Visible = 0 'False
Width = 5670
_ExtentX = 10001
_ExtentY = 661
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.CommandButton Command1
Caption = "Keluar"
Height = 495
Index = 1
Left = 3480
TabIndex = 8
Top = 1920
Width = 1935
End
Begin VB.CommandButton Command1
Caption = "Proses"
Height = 495
Index = 0
Left = 3480
TabIndex = 7
Top = 1080
Width = 1935
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 3480
Locked = -1 'True
TabIndex = 6
Top = 520
Width = 1935
End
Begin VB.Frame Frame1
Caption = "Pilihan Alat Tulis:"
Height = 1335
Left = 240
TabIndex = 0
Top = 240
Width = 3015
Begin VB.CheckBox Check1
Caption = "Penghapus"
Height = 495
Index = 3
Left = 1680
TabIndex = 4
Top = 720
Width = 1215
End
Begin VB.CheckBox Check1
Caption = "Pencil"
Height = 495
Index = 2
Left = 240
TabIndex = 3
Top = 720
Width = 1215
End
Begin VB.CheckBox Check1
Caption = "Pena"
Height = 495
Index = 1
Left = 1680
TabIndex = 2
Top = 240
Width = 1215
End
Begin VB.CheckBox Check1
Caption = "Buku Tulis"
Height = 495
Index = 0
Left = 240
TabIndex = 1
Top = 240
Width = 1215
End
End
Begin VB.Line Line1
Index = 0
X1 = 5400
X2 = 120
Y1 = 1800
Y2 = 1800
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Total Bayar:"
Height = 225
Left = 3480
TabIndex = 5
Top = 240
Width = 930
End
Begin VB.Line Line1
BorderColor = &H00FFFFFF&
BorderWidth = 4
Index = 1
X1 = 5400
X2 = 120
Y1 = 1800
Y2 = 1800
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0:
If Command1(Index).Caption = "Proses" Then
Dim Harga_Buku%, Harga_Pena%, Harga_Pencil%, Harga_Penghapus%
If Check1(Index).Value = 1 Then Harga_Buku = 6000
If Check1(1).Value = 1 Then Harga_Pena = 4500
If Check1(2).Value = 1 Then Harga_Pencil = 1200
If Check1(3).Value = 1 Then Harga_Penghapus = 500
Dim Total_Bayar@
Total_Bayar = Harga_Buku + Harga_Pena + Harga_Pencil + Harga_Penghapus
Text1.Text = Format(Total_Bayar, "Currency")
Command1(Index).Caption = "Baru"
Else
Dim i%
For i = 0 To 3
Check1(i).Value = 0
Next
Text1.Text = Empty
Command1(Index).Caption = "Proses"
End If
Case 1:
Unload Me
End Select
End Sub

Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Keluar program ?", vbQuestion + vbYesNo, "Perhatian") = vbNo Then
Cancel = 1
End If
End Sub


Unduh Kode Sumber

Label:

0 Komentar:

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda