Coding untuk membantu pencarian data dan menampilkan hasilnya dalam bentuk dokumen sederhana dan file teks

Coding untuk membantu pencarian data dan menampilkan hasilnya dalam bentuk dokumen sederhana dan file teks

Private Sub cmdClearSearch_Click()
‘tombol cmdClearSearch di frmADOCode diklik…
frmADOCode.cmdClearSearch.Value = True
End Sub

Private Sub cmdFindFirst_Click()
‘tombol FindFirst di frmADOCode diklik…
frmADOCode.cmdFindFirst.Value = True
End Sub

Private Sub cmdFindNext_Click()
‘tombol FindNext di frmADOCode diklik…
frmADOCode.cmdFindNext.Value = True
End Sub

Private Sub cmdOK_Click()
Me.Hide
End Sub

Private Sub cmdSimpan_Click()
On Error GoTo Batal ‘Jika batal menyimpan file pergi ke Batal
If Text1.Text <> “” Then
With Dialog
.DialogTitle = “Simpan sebagai file teks”
.Filter = “*.txt|*.txt” ‘Hanya file txt yg bisa disimpan
.FileName = “HasilCari”
.ShowSave ‘Tampilkan kotak dialog simpan file
Open .FileName For Output As #1 ‘Simpan ke file
Print #1, Text1.Text
Close #1 ‘Tutup file
End With: Exit Sub
Else
MsgBox “Belum ada hasil pencarian!”, vbCritical, “Kosong”
Exit Sub
End If
Batal: ‘Label jika batal menyimpan
Exit Sub ‘Langsung keluar dari prosedur ini
End Sub

oleh: Masino Sinaga (masino_sinaga@posindonesia.co.id)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: