horeee berhasiiill... terima kasih pak! :) On 7/2/07, Taufik <[EMAIL PROTECTED]> wrote: > > Hai, > 1. buat project baru > 2. tambahkan project references: Microsoft Scripting Runtime > 3. dalam form, tambahkan Command1 dan Command2 (button) > 4. Copy paste code dibawah ini > > '=========================================================== > Private mFSO As New FileSystemObject > Private mFile1 As File > Private mts As TextStream > Private mFileSpec As String > > Option Explicit > > Private Sub Command1_Click() > ProsedurTulisIsiText > End Sub > > Private Sub Command2_Click() > ProsedurHapusIsiText > End Sub > > Private Sub ProsedurHapusIsiText() > 'Menghapus isi text dalam "C:\Text.txt" > Dim vText As String > mFileSpec = "C:\Text.txt" > If mFSO.FileExists(mFileSpec) Then > 'hapus seluruh isi text file tanpa kecuali > Set mFile1 = mFSO.GetFile(mFileSpec) > Set mts = mFile1.OpenAsTextStream(ForWriting) > mts.Write "" > Else > MsgBox "Text.txt not found, can not erase file content", 48 > End If > End Sub > > Private Sub ProsedurTulisIsiText() > 'Menulis di File text "C:\Text.txt" > mFileSpec = "C:\Text.txt" > If mFSO.FileExists(mFileSpec) Then > 'Tulis beberapa baris dalam text file > Set mFile1 = mFSO.GetFile(mFileSpec) > Set mts = mFile1.OpenAsTextStream(ForWriting) > mts.Write "Hello World1" > Else > 'Create New File > Open mFileSpec For Output As #1 > Print #1, "Hello World" > Close #1 > End If > End Sub > > '=========================================================== > > Keterangan: > Command1 akan membuat sebuah file "Text.txt" di root C:, nama file > dapat dirubah sesuai dengan yang diinginkan, coba edit isi file > tersebut dengan menulis cerita sepanjang apapun. > > Command2 akan menghapus semua text dalam file tersebut. > Metodenya begitu > > supaya otomatis menghapus isi file pada saat program ditutup, maka > sebelum command "End", aktifkan dulu ProsedurHapusIsiText(). > > Semoga membantu, > F > in Code we trust.. > > --- In [email protected] <indoprog-vb%40yahoogroups.com>, "Indra > Satriani" <[EMAIL PROTECTED]> > wrote: > > > > Program saya memakai 1 file txt yang diisi ketika program > dijalankan. Nah > > saya ingin isi dari file itu dihapus (bukan menghapus filenya) > ketika > > program ditutup. Mohon pencerahannya. > > > > -- > > --- > > Is adult entertainment killing our children? Or is killing our > children > > entertaining adults? > > http://bayuindra.wordpress.com > > http://deciana.wordpress.com > > > > > > [Non-text portions of this message have been removed] > > > > >
-- --- Is adult entertainment killing our children? Or is killing our children entertaining adults? http://bayuindra.wordpress.com http://deciana.wordpress.com [Non-text portions of this message have been removed]
