0% found this document useful (0 votes)
47 views

Disain Form SBB:: Langkah-Langkah Untuk Menyusun Praktikum I, Adl

The document provides steps to create a Visual Basic 6.0 programming practical exercise involving creating forms with various components like text boxes, combo boxes, check boxes and command buttons. It involves designing the form, setting properties of components, writing code for events like clicking buttons. The code performs operations like adding items to combo boxes based on selection, clearing fields on clicking reset button, showing message on clicking ok button.

Uploaded by

Wira Wiryadi
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Disain Form SBB:: Langkah-Langkah Untuk Menyusun Praktikum I, Adl

The document provides steps to create a Visual Basic 6.0 programming practical exercise involving creating forms with various components like text boxes, combo boxes, check boxes and command buttons. It involves designing the form, setting properties of components, writing code for events like clicking buttons. The code performs operations like adding items to combo boxes based on selection, clearing fields on clicking reset button, showing message on clicking ok button.

Uploaded by

Wira Wiryadi
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.

0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum I, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_1.VBP
: Fprak_1.Frm

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Frame1
Frame2
Text1
Text2
Text3
Command1
Command2
Command3
Command4
Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Caption = spaces
Caption = spaces
Name = txtnilaia
Text = spaces
Name = txtnilaib
Text = spaces
Name = txthasilproses
Text = spaces
Name = cmdtambah
Caption = +
Name = cmdkurang
Caption = Name = cmdbagi
Caption = /
Name = cmdkali
1 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Command5
Command6

Caption = *
Name = cmdpangkat
Caption = ^
Name = cmdexit
Caption = &Exit

3. Pada general ketik source program


Dim a, b As Long
Dim c As Single

4. Double click bagi isi source program


Private Sub cmdbagi_Click()
a = Val(txtnilaia.Text)
b = Val(txtnilaib.Text)
If a = 0 And b = 0 Then
response = MsgBox("Nilai A dan B tidak Boleh 0", 0, "Input NIlai A, B")
Exit Sub
End If
c=a/b
txthasilproses.Text = Str(c)
End Sub

5. Double click exit isi source program


Private Sub cmdexit_Click()
End
End Sub

6. Double click kali isi source program


Private Sub cmdkali_Click()
a = Val(txtnilaia.Text)
b = Val(txtnilaib.Text)
If a = 0 And b = 0 Then
response = MsgBox("Nilai A dan B tidak Boleh 0", 0, "Input NIlai A, B")
Exit Sub
End If
c=a*b
txthasilproses.Text = Str(c)
End Sub

Disajikan Oleh : Ir. H. Sumijan, M.Sc

2 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

7. Double click kurang isi source program


Private Sub cmdkurang_Click()
a = Val(txtnilaia.Text)
b = Val(txtnilaib.Text)
If a = 0 And b = 0 Then
response = MsgBox("Nilai A dan B tidak Boleh 0", 0, "Input NIlai A, B")
Exit Sub
End If
c=a-b
txthasilproses.Text = Str(c)
End Sub

8. Double click pangkat isi source program


Private Sub cmdpangkat_Click()
a = Val(txtnilaia.Text)
b = Val(txtnilaib.Text)
If a <= 0 And b <= 0 Then
response = MsgBox("Nilai A dan B tidak Boleh 0", 0, "Input NIlai A, B")
Exit Sub
End If
c=a^b
txthasilproses.Text = Str(c)
End Sub

9. Double click tambah isi source program


Private Sub cmdtambah_Click()
txthasilproses.Text = Val(txtnilaia.Text) + Val(txtnilaib.Text)
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

3 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 2, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_2.VBP
: Fprak_2.Frm

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Frame1
Frame2
Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Caption = spaces
Caption = spaces

4 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Frame3
Text1
Text2
Text3
Text4
Text5
Command1
Command2
Command3
Command6

Caption = spaces
Name = txta
Text = spaces
Name = txtb
Text = spaces
Name = txthasilint
Text = spaces
Name = txthasildouble
Text = spaces
Name = txthasilstring
Text = spaces
Name = cmdtambahint
Caption = Integer +
Name = cmdtambahdouble
Caption = Double+
Name = cmdtambahstring
Caption = String+
Name = cmdclose
Caption = &Close

3. click View | Project Explorer, kemudian double clicking pada


Form1(Form1) isi source program :
Private Function hitung(a, b As Integer)
hitung = a + b
End Function
Private Function hitung1(a, b As Double)
hitung1 = a + b
End Function
Private Function hitung2(a, b As String)
hitung2 = a + b
End Function

4. Double clicking pada Integer + isi source program :


Private Sub cmdtambahint_Click()
Dim a, b As Integer
a = Val(txta.Text)
b = Val(txtb.Text)
stxthasilint.Text = Str(hitung(a, b))
End Sub

5. Double clicking pada Double+ isi source program :


Private Sub cmdtambahdouble_Click()
Dim a, b As Double
a = Val(txta.Text)
Disajikan Oleh : Ir. H. Sumijan, M.Sc

5 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

b = Val(txtb.Text)
txthasildouble.Text = Str(hitung1(a, b))
End Sub

6. Double clicking pada String+ isi source program :


Private Sub cmdtambahstring_Click()
Dim a, b As String
a = txta.Text
b = txtb.Text
txthasilstring.Text = hitung2(a, b)
End Sub

7. Double clicking pada Close isi source program :


Private Sub cmdclose_Click()
Unload Me
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

6 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 3, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_3.VBP
: Fprak_3.Frm

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Frame1
Frame2
Frame3
Text1

Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Caption = spaces
Caption = spaces
Caption = spaces
Name = txtnobp
Text = spaces
7 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Text2
Text3
Text4
Text5
Command1
Command2
Command3

Name = txtnama
Text = spaces
Name = txtnilaiangka
Text = spaces
Name = txtnilaihuruf
Text = spaces
Name = txtketerangan
Text = spaces
Name = cmdprocess
Caption =&Process
Name = cmdulang
Caption = &Ulang
Name = cmdexit
Caption =&Exit

3. Pada general ketik source program


Dim ket As String * 15
Dim na As Single
Dim hrf As String * 2
Private Function cari(a As Single)
Select Case a
Case 80 To 100
hrf = "A": ket = "Terpuji"
Case 65 To 79
hrf = "B": ket = "Baik"
Case 55 To 64
hrf = "C": ket = "Cukup"
Case 35 To 54
hrf = "D": ket = "Kurang"
Case 0 To 34
hrf = "E": ket = "Jelek"
Case Else
hrf = "-": ket = "-"
End Select
End Function

4. Double clicking pada Exit isi source program :


Private Sub cmdexit_Click()
Unload Me
End Sub

5. Double clicking pada Process isi source program :


Private Sub cmdprocess_Click()
txtnilaihuruf.Enabled = False
txtketerangan.Enabled = False
na = Val(txtnilaiangka.Text)
Disajikan Oleh : Ir. H. Sumijan, M.Sc

8 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

cari (na)
txtnilaihuruf.Text = hrf
txtketerangan.Text = ket
End Sub

6. Double clicking pada Ulang isi source program :


Private Sub cmdulang_Click()
txtnilaiangka.Text = ""
txtnilaihuruf.Text = ""
txtketerangan.Text = ""
txtnobp.Text = ""
txtnama.Text = ""
txtnobp.SetFocus
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

9 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 4, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_4.VBP
: Fprak_4.Frm

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Frame1
Frame2
sFrame3
Frame4
Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Caption = spaces
Caption = spaces
Caption = spaces
Caption = spaces

10 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Text1
Text2
Text3
Combo1
Combo2
Combo3
Option1
Option2
Chechbox1
Chechbox2
Chechbox3
Chechbox4
Chechbox5
Chechbox6
Command1
Command2
Command3

Name = txtnpm
Text = spaces
Name = txtnama
Text = spaces
Name = txtasalslta
Text = spaces
Name = cbostatus
Text = spaces
Name = cbofakultas
Text = spaces
Name = cboprogramstudi
Text = spaces
Name = optlakilaki
Caption = Laki-Laki
Name = optwanita
Caption = wanita
Name = chkorkes
Caption = Olah raga
Name = chkprg
Caption = Programmer
Name = chkans
Caption = Analys
Name = chkbaca
Caption = Membaca
Name = chktulis
Caption = Menulis
Name = chkbrows
Caption = Browsing
Name = cmdOk
Caption =&Ok
Name = cmdulang
Caption = &Ulang
Name = cmdclose
Caption =&Close

3. Double clicking pada CboFakultas isi source program :


Private Sub Cbofakultas_Click()
cboprogramstudi.Clear
Select Case Trim(cbofakultas.Text)
Case "Ilmu Komputer"
cboprogramstudi.AddItem "Sistem Informasi"
cboprogramstudi.AddItem "Sistem Komputer"
cboprogramstudi.AddItem "Manajemen Informatika"
Case "Ekonomi"
cboprogramstudi.AddItem "Akutansi-S1"
cboprogramstudi.AddItem "Manajemen-S1"
Disajikan Oleh : Ir. H. Sumijan, M.Sc

11 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

cboprogramstudi.AddItem "Akutansi-D3"
cboprogramstudi.AddItem "Manajemen-D3"
Case "Teknologi Industri"
cboprogramstudi.AddItem "Teknik Elektro"
cboprogramstudi.AddItem "Teknik Industri"
Case "Teknik Sipil & Perencanaan"
cboprogramstudi.AddItem "Teknik Sipil"
cboprogramstudi.AddItem "Teknik Arsitektur"
Case "Psikologi"
cboprogramstudi.AddItem "Psikologi"
End Select
End Sub

4. Double clicking pada Close isi source program :


Private Sub cmdclose_Click()
Unload Me
End Sub

5. Double clicking pada Ok isi source program :


Private Sub cmdok_Click()
Dim x As Byte
x = MsgBox("Process Saving", vbOKOnly + vbInformation, "Message")
If x = vbOK Then
Exit Sub
End If
End Sub

6. Double clicking pada Ulang isi source program :


Private Sub cmdulang_Click()
txtnpm.Text = ""
txtnama.Text = ""
cbostatus.Text = ""
txtasalslta.Text = ""
cbofakultas.Text = ""
cboprogramstudi.Text = ""
optlakilaki.Value = False
optwanita.Value = False
chkorkes.Value = False
chkprg.Value = False
chkans.Value = False
chkbaca.Value = False
chktulis.Value = False
chkbrows.Value = False
txtnpm.SetFocus
End Sub

Disajikan Oleh : Ir. H. Sumijan, M.Sc

12 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

7. Double clicking pada Form isi source program :


Private Sub Form_Load()
cbofakultas.AddItem "Ilmu Komputer"
cbofakultas.AddItem "Ekonomi"
cbofakultas.AddItem "Teknologi Industri"
cbofakultas.AddItem "Teknik Sipil & Perencanaan"
cbofakultas.AddItem "Psikologi"
cbostatus.AddItem "Sendiri"
cbostatus.AddItem "Kawin"
cbostatus.AddItem "Janda"
cbostatus.AddItem "Duda"
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

13 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 5, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_5.VBP
: Fprak_5.Frm

1. Disain Form Sbb :

Disajikan Oleh : Ir. H. Sumijan, M.Sc

14 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

2. Setting Properties sbb :

Nama Component
Frame1
Frame2
Text1
Calender1
Command
Command
Command
Command
Command
Command
Command
Command
Command
Command
Command
Command
Command
Command
Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Caption = spaces
Caption = spaces
Name = tampilan
Text = spaces
Name = Calender1
Name = angka
Caption = 1
Index = 1
Name = angka
Caption = 2
Index = 2
Name = angka
Caption = 3
Index = 3
Name = angka
Caption = 4
Index = 4
Name = angka
Caption = 5
Index = 5
Name = angka
Caption = 6
Index = 6
Name = angka
Caption = 7
Index = 7
Name = angka
Caption = 8
Index = 8
Name = angka
Caption = 9
Index = 9
Name = tblhapus
Caption = C
Name = angka
Caption = 0
Index = 0
Name = Desimal
Caption = .
Name = TAmbahkurang
Caption = +/Name = Tambah
15 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Command
Command
Command
Command
Command

Caption = +
Name = kali
Caption = *
Name = Satuper
Caption =
Name = kurang
Caption = Name = bagi
Caption = /
Name = Samadengan
Caption = =

3. Pada general ketik source program


Option Explicit
Dim opr1 As Double, opr2 As Double
Dim operator As String
Dim hapustampilan As Boolean

4. Double click angka isi source program


Private Sub angka_Click(Index As Integer)
If hapustampilan Then
tampilan.Text = ""
hapustampilan = False
End If
tampilan.Text = tampilan.Text + Str(angka(Index).Index)
End Sub

5. Double click bagi isi source program


Private Sub bagi_Click(Index As Integer)
opr1 = Val(tampilan.Text)
operator = "/"
tampilan.Text = ""
End Sub

6. Double click desimal (.) isi source program


Private Sub desimal_Click(Index As Integer)
If hapustampilan Then
tampilan.Text = ""
hapustampilan = False
End If
If InStr(tampilan.Text, ".") Then
Exit Sub
Else
tampilan.Text = tampilan.Text + "."
End If
Disajikan Oleh : Ir. H. Sumijan, M.Sc

16 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

End Sub

7. Double click kali isi source program


Private Sub kali_Click(Index As Integer)
opr1 = Val(tampilan.Text)
operator = "*"
tampilan.Text = ""
End Sub

8. Double click kurang isi source program


Private Sub kurang_Click(Index As Integer)
opr1 = Val(tampilan.Text)
operator = "-"
tampilan.Text = ""
End Sub

9. Double click samadengan source program


Private Sub samadengan_Click(Index As Integer)
Dim x As Byte
Dim hasil As Double
On Error GoTo errorhandler
opr2 = Val(tampilan.Text)
If operator = "+" Then hasil = opr1 + opr2
If operator = "-" Then hasil = opr1 - opr2
If operator = "*" Then hasil = opr1 * opr2
If operator = "/" And opr2 <> "0" Then hasil = opr1 / opr2
tampilan.Text = Format(hasil, "###,###,###")
hapustampilan = True
Exit Sub
errorhandler:
x = MsgBox("Hitungan Salah", vbInformation & vbCrLf & Err.Description,
"Pesan SAlah")
tampilan.Text = "Salah"
End Sub

10.Double click satuper isi source program


Private Sub satuper_Click(Index As Integer)
If Val(tampilan.Text) <> 0 Then tampilan.Text = 1 / Val(tampilan.Text)
End Sub

11.Double click tambah isi source program


Private Sub tambah_Click(Index As Integer)
opr1 = Val(tampilan.Text)
operator = "+"
tampilan.Text = ""
End Sub
Disajikan Oleh : Ir. H. Sumijan, M.Sc

17 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

12.Double click tamabahkurang isi source program


Private Sub tambahkurang_Click(Index As Integer)
tampilan.Text = -Val(tampilan.Text)
End Sub

13.Double click tblhapus isi source program


Private Sub tblhapus_Click(Index As Integer)
tampilan.Text = ""
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

18 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 6, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_6.VBP
: Fprak_6.Frm

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Text1
Text2
Text3
Command1
Timer1

Properties
Name = txtnilaia
Text = spaces
Name = txtnilaia
Text = spaces
Name = txtnilaia
Text = spaces
Name = cmdStart
Caption =&Start
Name = timer1
Interval = 1000

3. Pada General isi source program


Public awal, akhir, lama As Single

Disajikan Oleh : Ir. H. Sumijan, M.Sc

19 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

4. Double click Start isi source program


Private Sub Command1_Click()
If Command1.Caption = "Start" Then
awal = Now()
Text1.Text = Format(awal, "hh:mm:ss")
Command1.Caption = "Stop"
ElseIf Command1.Caption = "Stop" Then
akhir = Now()
lama = akhir - awal
Text2.Text = Format(akhir, "hh:mm:ss")
Text3.Text = Format(lama, "hh:mm:ss")
End If
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

20 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 7, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_7.VBP
: Fprak_7.Frm

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Label1
Text1
Text2
List1

Properties
Name = Label1
Caption = Cara Menggunakan Keypress
Name = Text1
Text = spaces
Name = Text2
Text = spaces
Name = List1
Text = spaces

3. Double click Form isi source program


Private Sub Form_Load()
Dim i As Integer
Disajikan Oleh : Ir. H. Sumijan, M.Sc

21 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

For i = 0 To 10
List1.List(i) = i * 10 + 10
List1.ItemData(i) = i * 10 + 10
Next i
End Sub

4. Double click List1 isi source program


Private Sub List1_Click()
Text1.Text = List1.ItemData(List1.ListIndex)
Text2.Text = List1.List(List1.ListIndex)
End Sub

5. Double click Text2 isi source program


Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
keyscii = 0
End If
End Sub

6. Double click Text1 isi source program


Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
keyscii = 0
End If
End Sub

7. Double click List1 isi source program


Private Sub list1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
keyscii = 0
End If
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

22 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 8, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_8.VBP
: Fprak_8.Frm

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Label1
Label2
Label3
Text1
Text2
Text3

Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Name = Label1
Caption = Label1
Name = Label2
Caption = Label2
Name = Label3
Caption = Label3
Name = Text1
Text = spaces
Name = Text2
Text = spaces
Name = Text3
Text = spaces
23 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

List1
List2
Command1

Name = List1
Text = spaces
Name = Lsthasil
Text = spaces
Name = cmdExit
Caption =&Exit

3. Pada General isi source program


Public nilai1, nilai2 As Integer

4. Double click Command1 isi source program


Private Sub Command1_Click()
Unload Me
End Sub

5. Double click Form isi source program


Private Sub Form_Load()
Dim i As Integer
Dim str1 As String
str1 = "Nilai "
For i = 0 To 9
lbxhasil.List(i) = str1 + Str(i)
List1.List(i) = str1 + Chr(i + 65)
Next i
For i = 1 To 9
lbxhasil.ItemData(i) = i * 100
List1.ItemData(i) = i * 15
Next i
End Sub

6. Double click List2 isi source program


Private Sub lbxhasil_Click()
nilai1 = lbxhasil.ItemData(lbxhasil.ListIndex)
Label1(1).Caption = List1.List(List1.ListIndex)
Label1(0).Caption = lbxhasil.List(lbxhasil.ListIndex)
Label1(2).Caption = " Halil Kalinya"
Text1.Text = nilai1
Text3.Text = nilai1 * nilai2
End Sub

7. Double click List1 isi source program


Private Sub List1_Click()
nilai2 = List1.ItemData(List1.ListIndex)
Label1(1).Caption = List1.List(List1.ListIndex)
Label1(0).Caption = lbxhasil.List(lbxhasil.ListIndex)
Disajikan Oleh : Ir. H. Sumijan, M.Sc

24 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Label1(2).Caption = " Halil Kalinya"


Text2.Text = nilai2
Text3.Text = nilai1 * nilai2
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Langkah-Langkah Untuk Menyusun Praktikum 9, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

Disajikan Oleh : Ir. H. Sumijan, M.Sc

: Pprak_9.VBP
: Fprak_9.Frm

25 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Text1
Text1
Text1
Text1
Text1
Text1
Text1
Text1
Text1

Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Name = Text1(0)
Text = spaces
Name = Text(1)
Text = spaces
Name = Text(2)
Text = spaces
Name = Text1(3)
Text = spaces
Name = Text(4)
Text = spaces
Name = Text(5)
Text = spaces
Name = Text1(6)
Text = spaces
Name = Text(7)
Text = spaces
Name = Text(8)
Text = spaces
26 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Text1
Command1
Command2

Name = Text(9)
Text = spaces
Name = cmdProcess
Caption =&Process
Name = cmdExit
Caption =&Exit

3. Double click Command1 isi source program


Private Sub Command1_Click()
Dim a, b, c As Single
a = Text1(0).Text
b = Text1(1).Text
c=a*b
Text1(2).Text = c
End Sub

4. Double click Command2 isi source program


Private Sub Command2_Click()
End
End Sub

5. Double click Text1 isi source program


Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
If Index = 10 Then
Text1(0).SetFocus
Call Command1_Click
Else
Text1(Index + 1).SetFocus
End If
KeyAscii = 0
End If
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

27 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 10, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_10.VBP
: Fprak_10.Frm

1. Disain Form Sbb :

Disajikan Oleh : Ir. H. Sumijan, M.Sc

28 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

2. Setting Properties sbb :

Nama Component
Label1
Label2
Label3
Label4
Text1
Text2
Text3
Combo1

Properties
Name = Label1
Caption = Valuta Asing
Name = Label2
Caption =Jumlah
Name = Label3
Caption = Nilai Rupiah
Name = Label3
Caption = KURS
Name = Text1
Text = spaces
Name = Text2
Text = spaces
Name = Text3
Text = spaces
Name = Combo1
Text = spaces

3. Pada General isi source program


Dim kurs, nilairupiah As Single

4. Double click Combo1 isi source program


Private Sub Combo1_Click()
kurs = Combo1.ItemData(Combo1.ListIndex)
Text1.Text = Format(kurs, "###,###,###.#0")
Text2.SetFocus
Disajikan Oleh : Ir. H. Sumijan, M.Sc

29 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

End Sub
Private Sub Form_Load()
Combo1.List(0) = "Dollar US"
Combo1.List(1) = "Dollar AUS"
Combo1.List(2) = "Yen Jepang"
Combo1.List(3) = "Pound Inggris"
Combo1.List(4) = "Won Korea"
Combo1.ItemData(0) = 9600
Combo1.ItemData(1) = 3500
Combo1.ItemData(2) = 32
Combo1.ItemData(3) = 4500
Combo1.ItemData(4) = 5
End Sub

5. Double click Combo1 isi source program


Private Sub Text2_Change()
Text3.Text = Format(kurs * Val(Text2.Text), "###,###,###.#0")
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Langkah-Langkah Untuk Menyusun Praktikum 11, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

Disajikan Oleh : Ir. H. Sumijan, M.Sc

: Pprak_11.VBP
: Fprak_11.Frm

30 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Frame1
Frame2
Text1
Text1
Text1
Text1
Text1
Text1
Text1
Option1
Option2
Command1
Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Caption = spaces
Caption = Discount
Name = Text1(0)
Text = spaces
Name = Text(1)
Text = spaces
Name = Text(2)
Text = spaces
Name = Text1(3)
Text = spaces
Name = Text(4)
Text = spaces
Name = Text(5)
Text = spaces
Name = Text1(6)
Text = spaces
Name = Optya
Caption = Ya
Name = Opttidak
Caption = Tidak
Name = cmdmulai
31 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Command2

Caption =&Mulai
Name = cmdSelesai
Caption =&Selesai

3. Double click Mulai isi source program


Private Sub cmdmulai_Click()
Dim i As Byte
For i = 0 To 5
text1(i).Text = ""
Next i
text1(0).SetFocus
End Sub

4. Double click Mulai isi source program


Private Sub cmdselesai_Click()
End
End Sub

5. Double click Tidak isi source program


Private Sub opttidah_Click()
Dim nilai As Double
nilai = Val(text1(3).Text) * Val(text1(2).Text)
text1(5).Text = Format(nilai, "#,###")
End Sub

6. Double click Ya isi source program


Private Sub optya_Click()
Dim nilai, nilai1 As Double
nilai = Val(text1(3).Text) * Val(text1(2).Text)
nilai1 = 0.1 * nilai
text1(5).Text = Format(nilai1, "#,###")
End Sub

7. Double click Text1 isi source program


Private Sub text1_Change(Index As Integer)
Dim nilai, nilai1 As Double
nilai = Val(text1(3).Text) * Val(text1(2).Text)
text1(4).Text = Format(nilai, "#,###")
Hasil
pengamatan
If optya.Value
Then : (Untuk MenjalankanClick Run | Start)
nilai1 = 0.1 * nilai
text1(5).Text = Format(nilai1, "#,###")
Else
text1(5).Text = 0
End If
text1(6).Text = Format(nilai - nilai1, "#,###")
End Sub
Disajikan Oleh : Ir. H. Sumijan, M.Sc

32 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 12, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

Disajikan Oleh : Ir. H. Sumijan, M.Sc

: Pprak_12.VBP
: Fprak_12.Frm

33 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Frame1
Text1
Text2
Text3
Text4
Combo1
Combo2
Combo3
Label1
Label2
Label3

Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Caption = spaces
Name = txtnobp
Text = spaces
Name = txtnama
Text = spaces
Name = txtmutu
Text = spaces
Name = txtpredikat
Text = spaces
Name = cbojeniskelamin
Text = spaces
Name = cboasalslta
Text = spaces
Name = cbonilaihuruf
Text = spaces
Name = Label1
Caption = Input Data Mahasiswa
Name = Label1
Caption = Nobp
Name = Label1
Caption = Nama
34 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Label4
Label5
Label6
Label7
Label8
Command1
Command2
Command3

Name = Label1
Caption = Jenis Kelamin
Name = Label1
Caption = Asal SLTA
Name = Label1
Caption = Nilai Huruf
Name = Label1
Caption = Mutu
Name = Label1
Caption = Predikat
Name = cmdStart
Caption =&Start
Name = cmdUlang
Caption =&Ulang
Name = cmdClose
Caption =&Close

3. Buat Function dan isi source program


Function bform()
txtnobp.Text = ""
txtnama.Text = ""
txtmutu.Text = ""
txtpredikat.Text = ""
cbojeniskelamin.Text = ""
cboasalslta.Text = ""
cbonilaihuruf.Text = ""
txtnobp.SetFocus
End Function

4. Double Click Combo1(Nilai Huruf) isi source program


Private Sub cbonilaihuruf_Click()
Select Case cbonilaihuruf.List(cbonilaihuruf.ListIndex)
Case "A"
mutu = 4
pdk = "Sangat Memuaskan"
Case "B"
mutu = 3
pdk = "Memuaskan"
Case "C"
mutu = 2
Disajikan Oleh : Ir. H. Sumijan, M.Sc

35 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

pdk = "Cukup"
Case "D"
mutu = 1
pdk = "Kurang"
Case "E"
mutu = 0
pdk = "Sangat Kurang"
End Select
txtmutu.Text = mutu
txtpredikat.Text = pdk
End Sub

5. Double Click Start isi source program


Private Sub cmdstart_Click(Index As Integer)
Select Case Index
Case 0
Call bform
Case 1
Call bform
Case 2
Unload Me
End Select
End Sub

6. Double Click Pada Form isi source program


Private Sub Form_Load()
Dim i As Byte
cbojeniskelamin.List(0) = "Laki-Laki"
cbojeniskelamin.List(1) = "Perempuan"
cboasalslta.List(0) = "SMU"
cboasalslta.List(1) = "STM"
cboasalslta.List(2) = "MAN"
cboasalslta.List(3) = "SMK"
For i = 0 To 4
cbonilaihuruf.List(i) = Chr(i + 65)
Next
End Sub

7. Double Click TxtNobp isi source program


Private Sub txtnobp_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub
Private Sub txtnama_KeyPress(KeyAscii As Integer)
Disajikan Oleh : Ir. H. Sumijan, M.Sc

36 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

If KeyAscii = 13 Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub

8. Double Click CboJenisKelamin isi source program


Private Sub cbojeniskelamin_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub

9. Double Click CboAsalSLTA isi source program


Private Sub cboasalslta_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub

10.Double Click CboNilaihuruf isi source program


Private Sub cbonilaihuruf_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub

11.Double Click Txtmutu isi source program


Private Sub txtmutu_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub

12.Double Click TtxPredikat isi source program


Private Sub txtpredikat_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Disajikan Oleh : Ir. H. Sumijan, M.Sc

37 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

SendKeys "{tab}"
KeyAscii = 0
End If
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Langkah-Langkah Untuk Menyusun Praktikum 13, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

Disajikan Oleh : Ir. H. Sumijan, M.Sc

: Pprak_13.VBP
: Fprak_13.Frm

38 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Text1
Text2
Text3
Text4
Text5
Text6
Text7
Text8
Text9
Label1
Label2
Disajikan Oleh : Ir. H. Sumijan, M.Sc

Properties
Name = txtkb
Text = spaces
Name = txtnb
Text = spaces
Name = txtdb
Text = spaces
Name = txtjml
Text = spaces
Name = txthb
Text = spaces
Name = txtnp
Text = spaces
Name = txtdc
Text = spaces
Name = txttp
Text = spaces
Name = txtpc
Text = spaces
Name = Label1
Caption = Kode Barang
Name = Label2
39 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Label3
Label4
Label5
Label6
Label7
Label8
Label9
Label10

Caption = Nama Barang


Name = Label3
Caption = Satuan
Name = Label4
Caption = Jumlah
Name = Label5
Caption = Harga
Name = Label6
Caption = Nilai Penjualan
Name = Label7
Caption = Total Penjualan
Name = Label8
Caption = Discount
Name = Label9
Caption = Percent
Name = Label10
Caption = %

3. Double Click General isi source program


Dim np, tp, pc, dc As Double

4. Double Click TxtHB isi source program


Private Sub txthb_Change()
np = Val(txtjml.Text) * Val(txthb.Text)
If (np >= 100000) And (np < 500000) Then
pc = 0.1
ElseIf (np >= 500000) And (np < 1000000) Then
pc = 0.15
ElseIf (np >= 1000000) And (np < 1500000) Then
pc = 0.17
ElseIf (np >= 1500000) Then
pc = 0.2
End If
dc = pc * np
tp = np - dc
txtnp.Text = Format(np, "#,###")
txttp.Text = Format(tp, "#,###")
txtpc.Text = pc
txtdc.Text = Format(dc, "#,###")
End Sub

5. Double Click TxtJml isi source program


Private Sub txtjml_Change()
np = Val(txtjml.Text) * Val(txthb.Text)
If (np >= 100000) And (np < 500000) Then
pc = 0.1
Disajikan Oleh : Ir. H. Sumijan, M.Sc

40 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

ElseIf (np >= 500000) And (np < 1000000) Then


pc = 0.15
ElseIf (np >= 1000000) And (np < 1500000) Then
pc = 0.17
ElseIf (np >= 1500000) Then
pc = 0.2
End If
dc = pc * np
tp = np - dc
txtnp.Text = Format(np, "#,###")
txttp.Text = Format(tp, "#,###")
txtpc.Text = pc
txtdc.Text = Format(dc, "#,###")
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Langkah-Langkah Untuk Menyusun Praktikum 14, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_14.VBP
: Fprak_14.Frm

1. Disain Form Sbb :


Disajikan Oleh : Ir. H. Sumijan, M.Sc

41 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

2. Setting Properties sbb :

Nama Component
Frame1
Frame2
Frame3
Option1
Option2
Option3
Option4
Option5
Option6
Option7
Label1

Properties
Caption = spaces
Caption = spaces
Caption = spaces
Name =Option1
Caption = GREEN
Name =Option2
Caption =WHITE
Name =Option3
Caption = RED
Name =Option4
Caption = Italic On
Name =Option5
Caption = Italic Off
Name =Option6
Caption = Underline On
Name =Option7
Caption = Underline Off
Name =Label1
Caption = spaces

3. Double Click Form isi source program


Private Sub Form_Load()
Disajikan Oleh : Ir. H. Sumijan, M.Sc

42 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Label1 = "Visual Basic is The Best"


End Sub

4. Double Click Option1 isi source program


Private Sub Option1_Click(Index As Integer)
Label1.ForeColor = &HC000&
End Sub

5. Double Click Option2 isi source program


Private Sub Option2_Click()
Label1.ForeColor = &HFFFFFF
End Sub

6. Double Click Option3 isi source program


Private Sub Option3_Click()
Label1.ForeColor = &HFF
End Sub

7. Double Click Option4 isi source program


Private Sub Option4_Click()
Label1.FontItalic = True
End Sub

8. Double Click Option5 isi source program


Private Sub Option5_Click()
Label1.FontItalic = False
End Sub

9. Double Click Option6 isi source program


Private Sub Option6_Click()
Label1.FontUnderline = True
End Sub

10.Double Click Option7 isi source program


Private Sub Option7_Click()
Label1.FontUnderline = 0
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

43 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

Langkah-Langkah Untuk Menyusun Praktikum 15, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

Disajikan Oleh : Ir. H. Sumijan, M.Sc

: Pprak_15.VBP
: Fprak_15.Frm

44 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Frame1
Frame2
Data1
Text1
Text2
Text3
Command1
Command2
Command3

Properties
Caption = spaces
Caption = spaces
Name = Data1
Visible = False
Name = txtnobp
Text = spaces
Name = txtnama
Text = spaces
Name = txtkelas
Text = spaces
Name = cmdsave
Caption = &Save
Name = cmdcancel
Caption = &Cancel
Name = cmdexit
Caption = &Exit

3. Double Click General isi source program


Public dbmhs As Database
Public rsstudent As Recordset

4. Buat Function isi source program


Private Sub bform()
txtnobp.Text = ""
Disajikan Oleh : Ir. H. Sumijan, M.Sc

45 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

txtnobp.SetFocus
End Sub

5. Double Click Cancel isi source program


Private Sub cmdcancel_Click()
Call kosong
End Sub

6. Double Click Exit isi source program


Private Sub cmdexit_Click()
End
End Sub

7. Double Click Simpan isi source program


Private Sub cmdsimpan_Click()
Dim ms
ms = MsgBox("Apakah Sudah Benar ?", vbYesNo + vbQuestion, "Yakin")
If ms = vbYes Then
rsstudent.AddNew
rsstudent(0) = txtnobp.Text
rsstudent(1) = txtnama.Text
rsstudent(2) = txtkelas.Text
rsstudent.Update
Call bform
End If
End Sub

8. Double Click Form isi source program


Private Sub Form_Load()
Set dbmhs = OpenDatabase("C:\upisiam\prakvb2003\mahasiswa.mdb")
Set rsstudent = dbmhs.OpenRecordset("oldmhs")
rsstudent.Index = "Nomor_Bp"
End Sub

9. Double Click TxtNobp isi source program


Private Sub txtnobp_Change()
Dim Panjang As Byte
Panjang = Len(txtnobp.Text)
If Panjang < 8 Then
Exit Sub
End If
Disajikan Oleh : Ir. H. Sumijan, M.Sc

46 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

rsstudent.Seek "=", txtnobp.Text


If rsstudent.NoMatch Then
On Error Resume Next
Call kosong
End If
txtnobp.Text = rsstudent(0)
txtnama.Text = rsstudent(1)
txtkelas.Text = rsstudent(2)
End Sub

10.Buat Subroutine Kosong isi source program


Private Sub kosong()
txtnobp.Text = ""
txtnama.Text = ""
txtkelas.Text = ""
txtnobp.SetFocus
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Langkah-Langkah Untuk Menyusun Praktikum 16, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

: Pprak_16.VBP
: Fprak_16.Frm

1. Disain Form Sbb :

Disajikan Oleh : Ir. H. Sumijan, M.Sc

47 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

2. Setting Properties sbb :

Nama Component
Frame1
Frame2
Data1
Text1
Text2
Text3
Command1
Command2
Command3

Properties
Caption = spaces
Caption = spaces
Name = Data1
Visible = False
Name = txtnobp
Text = spaces
Name = txtnama
Text = spaces
Name = txtkelas
Text = spaces
Name = cmdsimpan
Caption = &Simpan
Name = cmdcancel
Caption = &Cancel
Name = cmdexit
Caption = &Exit

3. Pada General isi source program


Dim dbmahasiswa As Database
Dim rsmhs As Recordset

4. Double Click pada Cancel source program


Private Sub cmdcancel_Click()
blankform
Disajikan Oleh : Ir. H. Sumijan, M.Sc

48 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

txtnobp.SetFocus
End Sub

5. Double Click pada Exit source program


Private Sub cmdexit_Click()
Unload Me
End Sub

6. Double Click pada Save source program


Private Sub cmdsave_Click()
rsmhs.AddNew
rsmhs!nobp = txtnobp.Text
rsmhs!nama = txtnama.Text
rsmhs!kelas = txtkelas.Text
rsmhs.Update
txtnobp.SetFocus
End Sub

7. Double Click pada Form source program


Private Sub Form_Load()
Set dbmahasiswa = OpenDatabase("C:\upisiam\prakvb2003\mahasiswa.mdb")
Set rsmhs = dbmahasiswa.OpenRecordset("oldmhs")
rsmhs.Index = "nomor_bp"
blankform
End Sub

8. Double Click pada TxtNobp source program


Private Sub txtnobp_Change()
If Len(txtnobp.Text) < 8 Then
Exit Sub
End If
Dim mnobp As String
rsmhs.Seek "=", txtnobp.Text
If rsmhs.NoMatch Then
On Error Resume Next
blankform
txtnama.SetFocus
End If
Disajikan Oleh : Ir. H. Sumijan, M.Sc

49 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

txtnobp.Text = rsmhs!nobp
txtnama.Text = rsmhs!nama
txtkelas.Text = rsmhs!kelas
End Sub

11.Buat Function isi source program


Private Sub blankform()
txtnama.Text = ""
txtkelas.Text = ""
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Langkah-Langkah Untuk Menyusun Praktikum 17, adl:


Click Start | Program | Microsoft Visual Studio | Microsoft Visual Basic 6.0
Pilih Standard, kemudian pilih Open
Click File | Project, beri nama File sbb :
Nama File Project
Nama File Form

Disajikan Oleh : Ir. H. Sumijan, M.Sc

: Pprak_17.VBP
: Fprak_17.Frm

50 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

1. Disain Form Sbb :

2. Setting Properties sbb :

Nama Component
Frame1
Data1
MsFlexGrid1
Command1
Command2

Properties
Caption = spaces
Name = Data1
Visible = False
Name = Tabel
DataSource = Data1
Name = cmdPreview
Caption = &Preview
Name = cmdexit
Caption = &Exit

3. Buat Function isi source program


Private Sub cmdExit_Click()
Unload Me
End Sub

9. Double Click pada TxtNobp source program


Private Sub cmdPreview_Click()
Dim StrSQL As String
StrSQL = "select t1.nobp as Nobp, t1.nama as Nama, & _
t2.kode as Kode_Mtk, t2.nama as Nama_Mtk, t2.sks as Sks, " & _
" (t2.nquis*0.2)+(t2.nuts*0.3)+(t2.nuas*0.6)as Nrata " & _
Disajikan Oleh : Ir. H. Sumijan, M.Sc

51 of 52

Petunjuk Praktikum : OOP-II (Visual Basic 6.0 Programming)

" from tmhs t1, tnilai t2 " & _


" where t1.nobp=t2.nobp " & _
"order by (t2.nquis*0.2)+(t2.nuts*0.3)+(t2.nuas*0.6) desc"
With Data1
.DatabaseName = "C:\upisiam\prakvb2003\dbmhs.mdb"
.RecordSource = StrSQL
.Refresh
End With
End Sub

10.Double Click pada Form Isi ssource program


Private Sub Form_Load()
Data1.Refresh
End Sub

Hasil pengamatan : (Untuk MenjalankanClick Run | Start)

Disajikan Oleh : Ir. H. Sumijan, M.Sc

52 of 52

You might also like