follow

MEMBUAT PENGHANCUR DATA DENGAN VB6.0

--<> 1 buah TextBox

-> 1 buah Label

-> 2 buah Command Button

-> 1 buah CommonDialog

Atur tampilannya sesuai keinginan anda.





(4). Klik menu [View] lalu pilih [Code]. Salin code berikut pada area kerja anda.

Private Sub Form_Load()
Text1.Text = ""
Label1.Caption = ""
Command1.Caption = "BROWSE"
Command2.Caption = "DESTROY!"
Form1.Caption = "Penghancur Data"
End Sub
Private Sub Command1_Click()
'------------------------------------------------
'Mencari file target
'------------------------------------------------
Label1.Caption = ""
Text1.Text = ""
On Error GoTo ErrHandler
CommonDialog1.Filter = "All Files"
CommonDialog1.FilterIndex = 2
CommonDialog1.DialogTitle = "Open file to delete..."
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
ErrHandler:
Exit Sub
End Sub
Private Sub Command2_Click()
'------------------------------------------------
'Buka file target kemudian hapus seluruh isinya.
'------------------------------------------------
Open CommonDialog1.FileName For Output As #1
Print #1, ""
Close #1
'------------------------------------------------
'Ubah ekstensi file target menjadi .tmp
'------------------------------------------------
changeEX = ChangeFileExt(CommonDialog1.FileName, "tmp")
Label1.Caption = "DATA SUDAH DIHANCURKAN!!"
End Sub
Public Function ChangeFileExt(ByVal nama_file As String, ByVal ekstensi_baru As String) As Boolean
'------------------------------------------------
'Fungsi untuk mengubah ekstensi file
'------------------------------------------------
Dim x As Long
Dim xy As Long
Dim nama_baru As String
On Error Resume Next
ChangeFileExt = False
If nama_file = "" Then Exit Function
x = 0
Do
xy = x
x = InStr(x + 1, nama_file, ".", vbBinaryCompare)
Loop Until x = 0
If xy > 0 Then
nama_baru = Left(nama_file, xy - 1)
Else
nama_baru = nama_file
End If
nama_baru = nama_baru & "." & ekstensi_baru
Err.Clear
Name nama_file As nama_baru
Kill nama_baru
If Err.Number = 0 Then ChangeFileExt = True
End Function

(5). Compile hasil pekerjaan anda. Klik menu [File] [Make Project1.exe]. Beri nama data_destroyer.exe lalu klik [OK].



Cobalah untuk menghapus suatu file dengan aplikasi yang baru saja anda buat. Lalu cobalah recovery kembali data yang telah terhapus itu dengan software recovery data kesayangan anda. Lihat hasilnya.. ;)





III. PENUTUP

------------

Sekian, selamat mencoba.. ;)

Artikel Terkait

By Djenggot with 0 comments

0 comments:

Leave a Reply