|
|
 |
| VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

January 6th, 2006, 03:18 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Reading line by line from a .txt file
Hi,
i want to know how to read data from a .txt file using vb.net 2003 line by line, note that the lines have different sizes.
sorry for any inconveniences,but i am new to vb.net
thanks
|

January 10th, 2006, 12:59 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Look up the streamreader class (there are other ways to do what you want, but this is, I think, the simplest). Here is some example code from the help:
Code:
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("TestFile.txt")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Console.WriteLine(Line)
Loop Until line Is Nothing
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(E.Message)
End Try
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
|

January 13th, 2006, 02:30 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok thanks jeff, but if i want write the read content to an excel file,(could you please refer to a previous topic that i posted earlier in this forum).i want to read the data from a txt file and input it into excel file(of course in a formated way)
for ex if i read aaa bbb ccc from the text file i want it stored in the excel file (as in cells)
A B C
|aaa|bbb|ccc|
|

February 8th, 2006, 02:28 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i found an answer for the above question now i am able to write to excel file, if anyone is interested just google a little using the keywords excel automation :)
But i have a question, i have a program that writes to a txt file, i want to develop an application that listens to this txt file and when it changes, then automatically read it and perform some I/O operation, any one have an idea?(hope it is cleat)
thanks a lot!
|

February 9th, 2006, 12:26 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Look into the FileSystemWatcher class.
|

February 10th, 2006, 01:55 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok, thanks, i will look into it and see what i can do.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |