Click to See Complete Forum and Search --> : Visual Basic.NET--- How to open a text file and display the data into a datagrid.


Miss Piggy
October 13th, 2005, 04:54 AM
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.

HanneSThEGreaT
October 13th, 2005, 07:07 AM
Hello! :wave:
Here's an example I've found on PlanetSourceCode (http://www.planetsourcecode.com)

Hope it helps!

Miss Piggy
October 13th, 2005, 08:02 PM
Thank you. It helps.

Miss Piggy
October 13th, 2005, 08:07 PM
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.