CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Location
    Spain
    Posts
    34

    Visual Basic.NET--- How to open a text file and display the data into a datagrid.

    I am learning both Visual basic 6.0 and Visual Basic.NET. I'm not sure of how to import a text file to a datagrid.

    Sub Main()
    Dim objReader As New StreamReader("C:\Documents and Settings\attkxp1\Desktop\FYP-DataMiningTools\DataMining\DataMiningTool\FYP\Logs\HssRpcSvrLog.txt")
    Dim sLine As String = ""
    Dim arrText As New ArrayList

    Do
    sLine = objReader.ReadLine()
    If Not sLine Is Nothing Then
    arrText.Add(sLine)
    End If
    Loop Until sLine Is Nothing
    objReader.Close()

    For Each sLine In arrText
    Console.WriteLine(sLine)
    Next
    Console.ReadLine()
    End Sub
    ----took reference from the MSDN web site. Don't really know how or where should i start from.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Visual Basic.NET--- How to open a text file and display the data into a datagrid.

    Hello!
    Here's an example I've found on PlanetSourceCode

    Hope it helps!
    Last edited by HanneSThEGreaT; December 19th, 2008 at 02:57 AM.

  3. #3
    Join Date
    Oct 2005
    Location
    Spain
    Posts
    34

    Talking Re: Visual Basic.NET--- How to open a text file and display the data into a datagrid.

    Thank you. It helps.

  4. #4
    Join Date
    Oct 2005
    Location
    Spain
    Posts
    34

    Exclamation Re: Visual Basic.NET--- How to open a text file and display the data into a datagrid.

    Sorry, I have another question. How to break the data that has been loaded to the datagrid into meaning columns. How to write the back code for breaqking them into columns to group the data in the text file? Thank you.
    Last edited by Miss Piggy; October 16th, 2005 at 08:20 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured