How To Read TextFile In VB.Net Windows Application

Q.: Create a windows application in VB.Net 2008 which To Read TextFile .

In VB.Net 2008, sometimes we have require  To Read TextFile. This Example Shows How  To Read TextFile .

Compability:  Microsoft Visual Studio 2008 (Microsoft .Net Framework 3.5)

Source Code:

Imports System.IO
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim line As String
            Dim readFile As System.IO.TextReader = New  _
    StreamReader("D:textfile.txt")
            While True
                line = readFile.ReadLine()
                If line Is Nothing Then
                    Exit While
                Else
                    MsgBox(line)
                End If
            End While
            readFile.Close()
            readFile = Nothing
        Catch ex As IOException
            MsgBox(ex.ToString)
        End Try
    End Sub

End Class

Output:

Download Now (.Zip File 114 KB)…

1 Comments

  1. javad says:

    thanksssssssssss

0 Trackbacks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.