Friday, July 18, 2008




Imports System

Imports System.IO

Public Class Form1

'===== Read File ====='

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If File.Exists("c:\1.txt") = True Then

Dim S As StreamReader = New StreamReader("C:\1.txt")

Dim L As String

L = S.ReadLine

While (Not (L Is Nothing))

TextBox1.Text &= L & vbNewLine

L = S.ReadLine

End While

S.Close()

Else

MsgBox("C:\1.txt is no Exist")

End If

End Sub

'===== Write On File ====='

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim w As StreamWriter = New StreamWriter("C:\1.txt")

w.Write(TextBox1.Text)

w.Close()

End Sub

End Class

*Note: TextBox1 Multiline Property is set to True.

No comments: