Beranda > Kuliah > Coding

Coding


Option Explicit Dim db As DAO.Database Dim rs As DAO.Recordset Private Sub cmdClose_Click() End End Sub Private Sub Form_Load() Set db = OpenDatabase(“D:\2007-Semester2

\VB-RAD\Praktikum\Prak14-uts\pidel-97.mdb”)
End Sub

Private Sub Form_Unload(Cancel As Integer)
db.Close
End Sub

Private Sub cmdViewData_Click()
Dim hasil As String
Dim i As Integer
Dim cek As Boolean

cek = False
If (chkSpe.Value = vbChecked) Then
If (IsNumeric(txtFrom.Text) = True) Then
If (IsNumeric(txtTo.Text) = True) Then
Set rs = db.OpenRecordset(“SELECT * FROM mahasiswa WHERE NIM BETWEEN ” & txtFrom.Text & ” AND ” & txtTo.Text, dbOpenDynaset)
cek = True
Else
MsgBox ” Please enter numeric value”, vbCritical, ” Error”
txtTo.SetFocus
End If
Else
MsgBox ” Please enter numeric value”, vbCritical, ” Error”
txtTo.SetFocus
End If

Else
Set rs = db.OpenRecordset(“SELECT * FROM mahasiswa”, dbOpenDynaset)
cek = True
End If

If (cek = True) Then
If rs.EOF = True Then
MsgBox “No Data Found”, vbInformation, “Result”
Exit Sub
End If

i = 0
txtResult.Text = “”
Do
hasil = “”
i = i + 1
hasil = hasil & Format(i, “000”) & ” – ” & rs!NIM & ” – ” & rs!Nama & ” – ” & rs!Alamat & ” – “
txtResult.Text = txtResult.Text & hasil & vbCrLf
rs.MoveNext
Loop While Not rs.EOF

rs.Close
End If
End Sub

Regards

Kategori:Kuliah
  1. Belum ada komentar.
  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: