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 : “Pprak_15.VBP”
Nama File Form : “Fprak_15.Frm”
1. Disain Form Sbb :
2. Setting Properties sbb :
Nama Component Properties
Frame1 Caption = spaces Frame2 Caption = spaces Data1 Name = Data1 Visible = False Text1 Name = txtnobp Text = spaces Text2 Name = txtnama Text = spaces Text3 Name = txtkelas Text = spaces Command1 Name = cmdsave Caption = &Save
Caption = &Cancel Command3 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 = "" 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
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 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)
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 : “Pprak_17.VBP”
Nama File Form : “Fprak_17.Frm”
1. Disain Form Sbb :
2. Setting Properties sbb :
Nama Component Properties
Frame1 Caption = spaces Data1 Name = Data1 Visible = False MsFlexGrid1 Name = Tabel DataSource = Data1 Command1 Name = cmdPreview Caption = &Preview Command2 Name = cmdexit Caption = &Exit
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 " & _ " 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
2. Double Click pada Form Isi ssource program
Private Sub Form_Load() Data1.Refresh End Sub
Hasil pengamatan : (Untuk MenjalankanClick Run | Start)