I am trying to write a program in VB.NET for file reading , by using File.ReadAllLines(file.txt), How i can show output the program is following,there is no code for showing output what i can use???

Program:
Imports System.IO 
Module Module1 
Sub Main() 
Dim array As String() = 
File.ReadAllLines("file.txt") 
Dim line As String 
For Each line In array 
    Dim length As Integer = line.Length 
Next 
End Sub 
End Module

You can output the linies by displaying them in a TextBox or RichTextBox control. As a matter of convenience, the RichTextBox control has methods to read/write files. or if this is for debugging purposes you can use Debug.WriteLine, or Console.WriteLine for console applications. In this case something like

Module Module1

    Sub Main()

        Dim lines() As String = System.IO.File.ReadAllLines(myfile)

        For Each line As String In lines
            Console.WriteLine(line)
        Next

    End Sub

End Module

Try this:

Imports System.IO 
Module Module1 
    Sub Main() 
        Dim array As String() = File.ReadAllLines("file.txt") 
        'Dim line As String this is unnecessary for-each dims the variable automatically
        For Each line In array 
            Dim length As Integer = line.Length
            'have a textbox on the form and set multiline to true
            'this line will output each line to the textbox.
            'if the lines are double spaced take off the vbnewline on the end.
            textbox1.text=textbox1.text & array & vbnewline
        Next 
    End Sub 
End Module
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.