Cari Artikel Lain

Jumat, 09 Oktober 2009

Membaca dan menulis file .log atau .txt pada VB.net

Untuk memberikan report atau laporan yang berhubungan dengan berjalannya suatu program biasanya menggunakan file .log atau .txt. Bagaimana menulis dan membaca file tersebut dalam VB.Net ?
 
 
Membaca file .log

Dim nom As Object

Dim strTeks(2) As String

nom = FreeFile()

If Dir(My.Application.Info.DirectoryPath & "\re" & Format(Now, "yyMM") & ".log") <> "" Then

FileOpen(1, My.Application.Info.DirectoryPath & "\re" & Format(Now, "yyMM") & ".log", OpenMode.Binary)

strTeks(0) = InputString(1, LOF(1))

FileClose(1)

End If

TextBox1.text = strTeks(0)

 

Menulis file .log

Dim nom As Object

nom = FreeFile()

FileOpen(nom, My.Application.Info.DirectoryPath & "\re" & Format(Now, "yyMM") & ".log", OpenMode.Output)

PrintLine(nom, "Isi data teksnya disini")

FileClose(nom)

 

Semoga bermanfaat untuk semuanya.
 
 

1 komentar:

  1. kalo baca file doc,programnya ada g?
    bisa lihat isi docnya dengan VB

    BalasHapus